mirror of
https://github.com/RoboSats/robosats.git
synced 2024-09-11 14:05:51 +03:00
Improve LN retry handling and logs
This commit is contained in:
parent
8ce26ce213
commit
f5853c6e7b
@ -178,7 +178,10 @@ class Command(BaseCommand):
|
||||
self.stdout.write(f"Ln payment {str(lnpayment)} has no parent order!")
|
||||
return
|
||||
order = lnpayment.order_paid_LN
|
||||
if order.trade_escrow.status == LNPayment.Status.SETLED:
|
||||
if (
|
||||
order.trade_escrow.status == LNPayment.Status.SETLED
|
||||
and order.is_swap is False
|
||||
):
|
||||
follow_send_payment.delay(lnpayment.payment_hash)
|
||||
|
||||
def send_onchain_payments(self):
|
||||
@ -199,6 +202,7 @@ class Command(BaseCommand):
|
||||
if (
|
||||
order.trade_escrow.status == LNPayment.Status.SETLED
|
||||
and order.trade_escrow.num_satoshis >= onchainpayment.num_satoshis
|
||||
and order.is_swap is True
|
||||
):
|
||||
# Sends out onchainpayment
|
||||
LNNode.pay_onchain(
|
||||
|
21
api/tasks.py
21
api/tasks.py
@ -148,7 +148,7 @@ def follow_send_payment(hash):
|
||||
}
|
||||
|
||||
if response.status == 2: # Status 2 'SUCCEEDED'
|
||||
print(f"SUCCEEDED. Order: {order.id}. Hash: {hash}")
|
||||
print(f"Order: {order.id} SUCCEEDED. Hash: {hash}")
|
||||
lnpayment.status = LNPayment.Status.SUCCED
|
||||
lnpayment.fee = float(response.fee_msat) / 1000
|
||||
lnpayment.preimage = response.payment_preimage
|
||||
@ -184,8 +184,8 @@ def follow_send_payment(hash):
|
||||
results = {"succeded": False, "context": "The payout invoice has expired"}
|
||||
return results
|
||||
|
||||
if "payment is in transition" in str(e):
|
||||
print(f"Order: {order.id}. ALREADY IN TRANSITION. Hash: {hash}.")
|
||||
elif "payment is in transition" in str(e):
|
||||
print(f"Order: {order.id} ALREADY IN TRANSITION. Hash: {hash}.")
|
||||
|
||||
request = LNNode.routerrpc.TrackPaymentRequest(
|
||||
payment_hash=bytes.fromhex(hash)
|
||||
@ -196,6 +196,21 @@ def follow_send_payment(hash):
|
||||
):
|
||||
handle_response(response)
|
||||
|
||||
elif "invoice is already paid" in str(e):
|
||||
print(f"Order: {order.id} ALREADY PAID. Hash: {hash}.")
|
||||
|
||||
request = LNNode.routerrpc.TrackPaymentRequest(
|
||||
payment_hash=bytes.fromhex(hash)
|
||||
)
|
||||
|
||||
for response in LNNode.routerstub.TrackPaymentV2(
|
||||
request, metadata=[("macaroon", MACAROON.hex())]
|
||||
):
|
||||
handle_response(response)
|
||||
|
||||
else:
|
||||
print(str(e))
|
||||
|
||||
|
||||
@shared_task(name="payments_cleansing")
|
||||
def payments_cleansing():
|
||||
|
Loading…
Reference in New Issue
Block a user