Handle expired invoices that are in_flight

This commit is contained in:
Reckless_Satoshi 2023-04-25 04:46:07 -07:00
parent b9aaf9f1bc
commit b1e9081ff8
No known key found for this signature in database
GPG Key ID: 9C4585B561315571

View File

@ -551,6 +551,21 @@ class LNNode:
if "invoice expired" in str(e): if "invoice expired" in str(e):
print(f"Order: {order.id}. INVOICE EXPIRED. Hash: {hash}") print(f"Order: {order.id}. INVOICE EXPIRED. Hash: {hash}")
# An expired invoice can already be in-flight. Check.
try:
request = routerrpc.TrackPaymentRequest(
payment_hash=bytes.fromhex(hash)
)
for response in cls.routerstub.TrackPaymentV2(request):
handle_response(response, was_in_transit=True)
except Exception as e:
if "payment isn't initiated" in str(e):
print(
f"Order: {order.id}. The expired invoice had not been initiated. Hash: {hash}"
)
lnpayment.status = LNPayment.Status.EXPIRE lnpayment.status = LNPayment.Status.EXPIRE
lnpayment.last_routing_time = timezone.now() lnpayment.last_routing_time = timezone.now()
lnpayment.in_flight = False lnpayment.in_flight = False