mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-24 03:54:21 +01:00
skip change output amount verification during melt (#393)
* skip change output amount verification during melt * make format
This commit is contained in:
@@ -625,7 +625,7 @@ class Ledger(LedgerVerification, LedgerSpendingConditions):
|
||||
|
||||
# make sure that the outputs (for fee return) are in the same unit as the quote
|
||||
if outputs:
|
||||
await self._verify_outputs(outputs)
|
||||
await self._verify_outputs(outputs, skip_amount_check=True)
|
||||
assert outputs[0].id, "output id not set"
|
||||
outputs_unit = self.keysets[outputs[0].id].unit
|
||||
assert melt_quote.unit == outputs_unit.name, (
|
||||
|
||||
@@ -96,7 +96,9 @@ class LedgerVerification(LedgerSpendingConditions, SupportsKeysets, SupportsDb):
|
||||
if outputs and not self._verify_output_spending_conditions(proofs, outputs):
|
||||
raise TransactionError("validation of output spending conditions failed.")
|
||||
|
||||
async def _verify_outputs(self, outputs: List[BlindedMessage]):
|
||||
async def _verify_outputs(
|
||||
self, outputs: List[BlindedMessage], skip_amount_check=False
|
||||
):
|
||||
"""Verify that the outputs are valid."""
|
||||
logger.trace(f"Verifying {len(outputs)} outputs.")
|
||||
# Verify all outputs have the same keyset id
|
||||
@@ -108,7 +110,11 @@ class LedgerVerification(LedgerSpendingConditions, SupportsKeysets, SupportsDb):
|
||||
if not self.keysets[outputs[0].id].active:
|
||||
raise TransactionError("keyset id inactive.")
|
||||
# Verify amounts of outputs
|
||||
if not all([self._verify_amount(o.amount) for o in outputs]):
|
||||
# we skip the amount check for NUT-8 change outputs (which can have amount 0)
|
||||
if (
|
||||
not all([self._verify_amount(o.amount) for o in outputs])
|
||||
and not skip_amount_check
|
||||
):
|
||||
raise TransactionError("invalid amount.")
|
||||
# verify that only unique outputs were used
|
||||
if not self._verify_no_duplicate_outputs(outputs):
|
||||
|
||||
Reference in New Issue
Block a user