From 4ac3618fd728c93eb437fe610174a23c10fd819e Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Sun, 5 Jun 2022 09:15:40 -0700 Subject: [PATCH] Add routing timeout to .env --- .env-sample | 4 ++++ api/lightning/node.py | 5 +++-- api/tasks.py | 8 +++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.env-sample b/.env-sample index efc7b203..c989392e 100644 --- a/.env-sample +++ b/.env-sample @@ -91,11 +91,15 @@ INVOICE_AND_ESCROW_DURATION = 30 # Time to confim chat and confirm fiat (time to Fiat Sent confirmation) HOURS FIAT_EXCHANGE_DURATION = 24 +# ROUTING # Proportional routing fee limit (fraction of total payout: % / 100) PROPORTIONAL_ROUTING_FEE_LIMIT = 0.0002 # Base flat limit fee for routing in Sats (used only when proportional is lower than this) MIN_FLAT_ROUTING_FEE_LIMIT = 10 MIN_FLAT_ROUTING_FEE_LIMIT_REWARD = 2 +# Routing timeouts +REWARDS_TIMEOUT_SECONDS = 60 +PAYOUT_TIMEOUT_SECONDS = 60 # Reward tip. Reward for every finished trade in the referral program (Satoshis) REWARD_TIP = 100 diff --git a/api/lightning/node.py b/api/lightning/node.py index 4781b79c..ed79116c 100644 --- a/api/lightning/node.py +++ b/api/lightning/node.py @@ -238,7 +238,7 @@ class LNNode: if payout["expires_at"] < timezone.now(): payout["context"] = { - "bad_invoice": f"The invoice provided has already expired" + "bad_invoice": "The invoice provided has already expired" } return payout @@ -257,9 +257,10 @@ class LNNode: lnpayment.num_satoshis * float(config("PROPORTIONAL_ROUTING_FEE_LIMIT")), float(config("MIN_FLAT_ROUTING_FEE_LIMIT_REWARD")), )) # 200 ppm or 10 sats + timeout_seconds = int(config("PAYOUT_TIMEOUT_SECONDS")) request = routerrpc.SendPaymentRequest(payment_request=lnpayment.invoice, fee_limit_sat=fee_limit_sat, - timeout_seconds=30) + timeout_seconds=timeout_seconds) for response in cls.routerstub.SendPaymentV2(request, metadata=[("macaroon", diff --git a/api/tasks.py b/api/tasks.py index 85baff34..7b869c77 100644 --- a/api/tasks.py +++ b/api/tasks.py @@ -78,12 +78,14 @@ def follow_send_payment(hash): lnpayment.num_satoshis * float(config("PROPORTIONAL_ROUTING_FEE_LIMIT")), float(config("MIN_FLAT_ROUTING_FEE_LIMIT")), - )) # 200 ppm or 10 sats + )) # 1000 ppm or 10 sats + timeout_seconds = int(config("REWARRDS_TIMEOUT_SECONDS")) + request = LNNode.routerrpc.SendPaymentRequest( payment_request=lnpayment.invoice, fee_limit_sat=fee_limit_sat, - timeout_seconds=60, - ) # time out payment in 60 seconds + timeout_seconds=timeout_seconds, + ) order = lnpayment.order_paid try: