fix: lnd/lndrest failed canceled/expired invoices (#3143)
This commit is contained in:
parent
5818c3c2ba
commit
6a9089fd98
2 changed files with 17 additions and 6 deletions
|
|
@ -16,6 +16,7 @@ from lnbits.utils.crypto import AESCipher, random_secret_and_hash
|
||||||
|
|
||||||
from .base import (
|
from .base import (
|
||||||
InvoiceResponse,
|
InvoiceResponse,
|
||||||
|
PaymentFailedStatus,
|
||||||
PaymentPendingStatus,
|
PaymentPendingStatus,
|
||||||
PaymentResponse,
|
PaymentResponse,
|
||||||
PaymentStatus,
|
PaymentStatus,
|
||||||
|
|
@ -237,6 +238,9 @@ class LndWallet(Wallet):
|
||||||
if resp.settled:
|
if resp.settled:
|
||||||
return PaymentSuccessStatus(preimage=resp.r_preimage.hex())
|
return PaymentSuccessStatus(preimage=resp.r_preimage.hex())
|
||||||
|
|
||||||
|
if resp.state == "CANCELED":
|
||||||
|
return PaymentFailedStatus()
|
||||||
|
|
||||||
return PaymentPendingStatus()
|
return PaymentPendingStatus()
|
||||||
except grpc.RpcError as exc:
|
except grpc.RpcError as exc:
|
||||||
logger.warning(exc)
|
logger.warning(exc)
|
||||||
|
|
|
||||||
|
|
@ -225,15 +225,22 @@ class LndRestWallet(Wallet):
|
||||||
try:
|
try:
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
data = r.json()
|
data = r.json()
|
||||||
|
|
||||||
if r.is_error or not data.get("settled"):
|
|
||||||
# this must also work when checking_id is not a hex recognizable by lnd
|
|
||||||
# it will return an error and no "settled" attribute on the object
|
|
||||||
return PaymentPendingStatus()
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error getting invoice status: {e}")
|
logger.error(f"Error getting invoice status: {e}")
|
||||||
return PaymentPendingStatus()
|
return PaymentPendingStatus()
|
||||||
return PaymentSuccessStatus()
|
|
||||||
|
if r.is_error or data.get("settled") is None:
|
||||||
|
# this must also work when checking_id is not a hex recognizable by lnd
|
||||||
|
# it will return an error and no "settled" attribute on the object
|
||||||
|
return PaymentPendingStatus()
|
||||||
|
|
||||||
|
if data.get("settled") is True:
|
||||||
|
return PaymentSuccessStatus()
|
||||||
|
|
||||||
|
if data.get("state") == "CANCELED":
|
||||||
|
return PaymentFailedStatus()
|
||||||
|
|
||||||
|
return PaymentPendingStatus()
|
||||||
|
|
||||||
async def get_payment_status(self, checking_id: str) -> PaymentStatus:
|
async def get_payment_status(self, checking_id: str) -> PaymentStatus:
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue