use specific keyset for returned change (#351)

This commit is contained in:
callebtc
2023-10-29 08:57:25 -03:00
committed by GitHub
parent 48f732e9e7
commit 22e0ad4b57
2 changed files with 14 additions and 2 deletions

View File

@@ -315,7 +315,11 @@ class Ledger(LedgerVerification, LedgerSpendingConditions, LedgerLightning):
return promises
async def melt(
self, proofs: List[Proof], invoice: str, outputs: Optional[List[BlindedMessage]]
self,
proofs: List[Proof],
invoice: str,
outputs: Optional[List[BlindedMessage]],
keyset: Optional[MintKeyset] = None,
) -> Tuple[bool, str, List[BlindedSignature]]:
"""Invalidates proofs and pays a Lightning invoice.
@@ -386,6 +390,7 @@ class Ledger(LedgerVerification, LedgerSpendingConditions, LedgerLightning):
invoice_amount=invoice_amount,
ln_fee_msat=payment.fee_msat,
outputs=outputs,
keyset=keyset,
)
except Exception as e:

View File

@@ -243,10 +243,17 @@ async def test_melt(wallet1: Wallet):
assert fee_reserve_sat == 2
_, send_proofs = await wallet1.split_to_send(wallet1.proofs, total_amount)
await wallet1.pay_lightning(
melt_response = await wallet1.pay_lightning(
send_proofs, invoice=invoice.bolt11, fee_reserve_sat=fee_reserve_sat
)
assert melt_response.change
assert len(melt_response.change) == 1
# NOTE: we assume that we will get a token back from the same keyset as the ones we melted
# this could be wrong if we melted tokens from an old keyset but the returned ones are
# from a newer one.
assert melt_response.change[0].id == send_proofs[0].id
# verify that proofs in proofs_used db have the same melt_id as the invoice in the db
assert invoice.payment_hash
invoice_db = await get_lightning_invoice(