Skip to content

Commit

Permalink
Mint: Allow 0-valued amounts for blank outputs (#348)
Browse files Browse the repository at this point in the history
* allow 0 amount for blank outputs

* fix precommit as well
  • Loading branch information
callebtc authored Oct 18, 2023
1 parent 3e58670 commit cfab668
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ repos:
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.6.0
hooks:
- id: mypy
args: [--ignore-missing]
# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.6.0
# hooks:
# - id: mypy
# args: [--ignore-missing]
4 changes: 2 additions & 2 deletions cashu/mint/ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,8 @@ async def melt(
f" {total_provided}, needed: {invoice_amount + fees_sat}"
)

# verify spending inputs, outputs, and spending conditions
await self.verify_inputs_and_outputs(proofs, outputs)
# verify spending inputs and their spending conditions
await self.verify_inputs_and_outputs(proofs)

if settings.lightning:
logger.trace(f"paying lightning invoice {invoice}")
Expand Down
6 changes: 2 additions & 4 deletions cashu/mint/verification.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,8 @@ def _verify_no_duplicate_outputs(self, outputs: List[BlindedMessage]) -> bool:
return True

def _verify_amount(self, amount: int) -> int:
"""Any amount used should be a positive integer not larger than 2^MAX_ORDER."""
valid = (
isinstance(amount, int) and amount > 0 and amount < 2**settings.max_order
)
"""Any amount used should be positive and not larger than 2^MAX_ORDER."""
valid = amount > 0 and amount < 2**settings.max_order
logger.trace(f"Verifying amount {amount} is valid: {valid}")
if not valid:
raise NotAllowedError("invalid amount: " + str(amount))
Expand Down
2 changes: 1 addition & 1 deletion cashu/wallet/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ async def pay_lightning(
# amount of fees we overpaid.
n_return_outputs = calculate_number_of_blank_outputs(fee_reserve_sat)
secrets, rs, derivation_paths = await self.generate_n_secrets(n_return_outputs)
outputs, rs = self._construct_outputs(n_return_outputs * [1], secrets, rs)
outputs, rs = self._construct_outputs(n_return_outputs * [0], secrets, rs)

status = await super().pay_lightning(proofs, invoice, outputs)

Expand Down

0 comments on commit cfab668

Please sign in to comment.