mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-24 03:54:21 +01:00
Mint: Allow 0-valued amounts for blank outputs (#348)
* allow 0 amount for blank outputs * fix precommit as well
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -457,8 +457,8 @@ class Ledger(LedgerVerification, LedgerSpendingConditions):
|
||||
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}")
|
||||
|
||||
@@ -139,10 +139,8 @@ class LedgerVerification(LedgerSpendingConditions, SupportsKeysets):
|
||||
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))
|
||||
|
||||
@@ -797,7 +797,7 @@ class Wallet(LedgerAPI, WalletP2PK, WalletHTLC, WalletSecrets):
|
||||
# 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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user