mirror of
https://github.com/aljazceru/nutshell.git
synced 2026-01-06 18:34:20 +01:00
use specific keyset for returned change (#351)
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user