From db2d7cc9226712d0a9863bb2b40ad99a7197f3be Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Sun, 6 Feb 2022 06:50:42 -0800 Subject: [PATCH] Small fixes --- api/lightning/node.py | 21 +++++---------------- api/management/commands/follow_invoices.py | 4 ++-- frontend/src/components/TradeBox.js | 2 +- 3 files changed, 8 insertions(+), 19 deletions(-) diff --git a/api/lightning/node.py b/api/lightning/node.py index cbcdbf25..b8caa8af 100644 --- a/api/lightning/node.py +++ b/api/lightning/node.py @@ -122,22 +122,11 @@ class LNNode(): lnpayment.save() return True - # @classmethod - # def check_until_invoice_locked(cls, payment_hash, expiration): - # '''Checks until hold invoice is locked. - # When invoice is locked, returns true. - # If time expires, return False.''' - # # Experimental, might need asyncio. Best if subscribing all invoices and running a background task - # # Maybe best to pass LNpayment object and change status live. - - # request = invoicesrpc.SubscribeSingleInvoiceRequest(r_hash=payment_hash) - # for invoice in cls.invoicesstub.SubscribeSingleInvoice(request): - # print(invoice) - # if timezone.now > expiration: - # break - # if invoice.state == 3: # True if hold invoice is accepted. - # return True - # return False + @classmethod + def resetmc(cls): + request = routerrpc.ResetMissionControlRequest() + response = cls.routerstub.ResetMissionControl(request, metadata=[('macaroon', MACAROON.hex())]) + return True @classmethod diff --git a/api/management/commands/follow_invoices.py b/api/management/commands/follow_invoices.py index 0fb8025a..e824b30b 100644 --- a/api/management/commands/follow_invoices.py +++ b/api/management/commands/follow_invoices.py @@ -129,7 +129,7 @@ class Command(BaseCommand): queryset_retries = LNPayment.objects.filter(type=LNPayment.Types.NORM, status__in=[LNPayment.Status.VALIDI, LNPayment.Status.FAILRO], - routing_attempts__lt=4, + routing_attempts__lt=5, last_routing_time__lt=(timezone.now()-timedelta(minutes=int(config('RETRY_TIME'))))) queryset = queryset.union(queryset_retries) @@ -142,7 +142,7 @@ class Command(BaseCommand): LNNode.resetmc() # If already 3 attempts and last failed. Make it expire (ask for a new invoice) an reset attempts. - if not success and lnpayment.routing_attempts == 3: + if not success and lnpayment.routing_attempts > 2: lnpayment.status = LNPayment.Status.EXPIRE lnpayment.routing_attempts = 0 lnpayment.save() diff --git a/frontend/src/components/TradeBox.js b/frontend/src/components/TradeBox.js index 59048557..61e56415 100644 --- a/frontend/src/components/TradeBox.js +++ b/frontend/src/components/TradeBox.js @@ -775,7 +775,7 @@ handleRatingRobosatsChange=(e)=>{ - Your invoice has expires or more than 3 payments have been attempted. + Your invoice has expires or more than 3 payments attempts have been made.