WIP: New melt flow (#622)

* `PaymentResult`

* ledger: rely on PaymentResult instead of paid flag. Double check for payments marked pending.

* `None` is `PENDING`

* make format

* reflected changes API tests where `PaymentStatus` is used + reflected changes in lnbits

* reflect changes in blink backend and tests

* fix lnbits get_payment_status

* remove paid flag

* fix mypy

* remove more paid flags

* fix strike mypy

* green

* shorten all state checks

* fix

* fix some tests

* gimme 

* fix............

* fix lnbits

* fix error

* lightning refactor

* add more regtest tests

* add tests for pending state and failure

* shorten checks

* use match case for startup check - and remember modified checking_id from pay_invoice

* fix strike pending return

* new tests?

* refactor startup routine into get_melt_quote

* test with purge

* refactor blink

* cleanup responses

* blink: return checking_id on failure

* fix lndgrpc try except

* add more testing for melt branches

* speed things up a bit

* remove comments

* remove comments

* block pending melt quotes

* remove comments

---------

Co-authored-by: lollerfirst <lollerfirst@gmail.com>
This commit is contained in:
callebtc
2024-09-24 14:55:35 +02:00
committed by GitHub
parent 25f0763f94
commit d8d3037cc5
39 changed files with 1575 additions and 682 deletions

View File

@@ -222,7 +222,7 @@ async def pay(
print(" Error: Balance too low.")
return
send_proofs, fees = await wallet.select_to_send(
wallet.proofs, total_amount, include_fees=True
wallet.proofs, total_amount, include_fees=True, set_reserved=True
)
try:
melt_response = await wallet.melt(
@@ -231,11 +231,25 @@ async def pay(
except Exception as e:
print(f" Error paying invoice: {str(e)}")
return
print(" Invoice paid", end="", flush=True)
if melt_response.payment_preimage and melt_response.payment_preimage != "0" * 64:
print(f" (Preimage: {melt_response.payment_preimage}).")
if (
melt_response.state
and MintQuoteState(melt_response.state) == MintQuoteState.paid
):
print(" Invoice paid", end="", flush=True)
if (
melt_response.payment_preimage
and melt_response.payment_preimage != "0" * 64
):
print(f" (Preimage: {melt_response.payment_preimage}).")
else:
print(".")
elif MintQuoteState(melt_response.state) == MintQuoteState.pending:
print(" Invoice pending.")
elif MintQuoteState(melt_response.state) == MintQuoteState.unpaid:
print(" Invoice unpaid.")
else:
print(".")
print(" Error paying invoice.")
await print_balance(ctx)