Wallet: add Wallet.get_melt_proof(), recover reserved state in failed Wallet.melt() (#730)

* manage state of proofs

* test set proofs unreserved

* melt recovers state on error

* fix wallet test

* fix tests

* fix another test

* get_mint_quote returns MintQuote

* fix tests

* refactor

* fix deprecated tests

* add new unset type
This commit is contained in:
callebtc
2025-04-25 13:12:45 +02:00
committed by GitHub
parent 213d5b1eee
commit 7f962ce63e
11 changed files with 482 additions and 75 deletions

View File

@@ -456,8 +456,8 @@ async def invoice(
while time.time() < check_until and not paid:
await asyncio.sleep(5)
try:
mint_quote_resp = await wallet.get_mint_quote(mint_quote.quote)
if mint_quote_resp.state == MintQuoteState.paid.value:
mint_quote = await wallet.get_mint_quote(mint_quote.quote)
if mint_quote.state == MintQuoteState.paid:
await wallet.mint(
amount,
split=optional_split,
@@ -527,8 +527,8 @@ async def swap(ctx: Context):
mint_quote = await incoming_wallet.request_mint(amount)
# pay invoice from outgoing mint
melt_quote_resp = await outgoing_wallet.melt_quote(mint_quote.request)
total_amount = melt_quote_resp.amount + melt_quote_resp.fee_reserve
melt_quote = await outgoing_wallet.melt_quote(mint_quote.request)
total_amount = melt_quote.amount + melt_quote.fee_reserve
if outgoing_wallet.available_balance < total_amount:
raise Exception("balance too low")
send_proofs, fees = await outgoing_wallet.select_to_send(
@@ -537,8 +537,8 @@ async def swap(ctx: Context):
await outgoing_wallet.melt(
send_proofs,
mint_quote.request,
melt_quote_resp.fee_reserve,
melt_quote_resp.quote,
melt_quote.fee_reserve,
melt_quote.quote,
)
# mint token in incoming mint