diff --git a/api/logics.py b/api/logics.py index 6d6aa8cb..f88ce41d 100644 --- a/api/logics.py +++ b/api/logics.py @@ -49,7 +49,7 @@ class Logics(): return False, {'bad_request':'You are already taker of an active order'}, queryset[0] # Edge case when the user is in an order that is failing payment and he is the buyer - queryset = Order.objects.filter( Q(maker=user) | Q(taker=user), status__in=Order.Status.FAI) + queryset = Order.objects.filter( Q(maker=user) | Q(taker=user), status=Order.Status.FAI) if queryset.exists(): order = queryset[0] if cls.is_buyer(order, user): @@ -794,13 +794,20 @@ class Logics(): # RETURN THE BONDS // Probably best also do it even if payment failed cls.return_bond(order.taker_bond) cls.return_bond(order.maker_bond) - is_payed, context = follow_send_payment(order.payout) ##### !!! KEY LINE - PAYS THE BUYER INVOICE !!! - if is_payed: - order.save() - return True, context - else: - # error handling here - return False, context + ##### !!! KEY LINE - PAYS THE BUYER INVOICE !!! + ##### Backgroun process "follow_invoices" will try to pay this invoice until success + order.status = Order.Status.PAY + order.payout.status = LNPayment.Status.FLIGHT + order.payout.save() + order.save() + return True, None + # is_payed, context = follow_send_payment(order.payout) ##### !!! KEY LINE - PAYS THE BUYER INVOICE !!! + # if is_payed: + # order.save() + # return True, context + # else: + # # error handling here + # return False, context else: return False, {'bad_request':'You cannot confirm the fiat payment at this stage'} diff --git a/api/management/commands/follow_invoices.py b/api/management/commands/follow_invoices.py index 7f7dbec9..2a7e1abf 100644 --- a/api/management/commands/follow_invoices.py +++ b/api/management/commands/follow_invoices.py @@ -27,7 +27,7 @@ class Command(BaseCommand): try: self.follow_hold_invoices() - self.retry_payments() + self.send_payments() except Exception as e: if 'database is locked' in str(e): self.stdout.write('database is locked') @@ -117,15 +117,25 @@ class Command(BaseCommand): self.stdout.write(str(timezone.now())) self.stdout.write(str(debug)) - def retry_payments(self): - ''' Checks if any payment is due for retry, and tries to pay it''' + def send_payments(self): + ''' + Checks for invoices that are due to pay; i.e., INFLIGHT status and 0 routing_attempts. + Checks if any payment is due for retry, and tries to pay it. + ''' queryset = LNPayment.objects.filter(type=LNPayment.Types.NORM, + status=LNPayment.Status.FLIGHT, + routing_attempts=0) + + queryset_retries = LNPayment.objects.filter(type=LNPayment.Types.NORM, status__in=[LNPayment.Status.VALIDI, LNPayment.Status.FAILRO], routing_attempts__lt=4, last_routing_time__lt=(timezone.now()-timedelta(minutes=int(config('RETRY_TIME'))))) + + queryset = queryset.union(queryset_retries) + for lnpayment in queryset: - success, _ = follow_send_payment(lnpayment) + success, _ = follow_send_payment(lnpayment) # Do follow_send_payment.delay() for further concurrency. # 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: diff --git a/api/tasks.py b/api/tasks.py index e22be46f..3f93ee90 100644 --- a/api/tasks.py +++ b/api/tasks.py @@ -77,7 +77,6 @@ def follow_send_payment(lnpayment): order.save() context = {'routing_failed': LNNode.payment_failure_context[response.failure_reason]} print(context) - # Call a retry in 5 mins here? return False, context if response.status == 2 : # Status 2 'SUCCEEDED' diff --git a/frontend/src/components/BookPage.js b/frontend/src/components/BookPage.js index 802a2538..1dc9572a 100644 --- a/frontend/src/components/BookPage.js +++ b/frontend/src/components/BookPage.js @@ -227,11 +227,9 @@ export default class BookPage extends Component { render() { return ( - - - Order Book - - + {/* + ORDER BOOK + */} diff --git a/frontend/src/components/MakerPage.js b/frontend/src/components/MakerPage.js index 34d0ab70..e10d78ae 100644 --- a/frontend/src/components/MakerPage.js +++ b/frontend/src/components/MakerPage.js @@ -153,12 +153,12 @@ export default class MakerPage extends Component { render() { return ( - - - - Order Maker + + {/* + + ORDER MAKER - + */} diff --git a/frontend/static/css/index.css b/frontend/static/css/index.css index 01a9d265..2818837a 100644 --- a/frontend/static/css/index.css +++ b/frontend/static/css/index.css @@ -67,16 +67,19 @@ body { filter: drop-shadow(0.5px 0.5px 0.5px #000000); } -.phoneFlippedSmallAvatar { +.phoneFlippedSmallAvatar img{ transform: scaleX(-1); - border: 1.3px solid #555; - filter: drop-shadow(0.7px 0.7px 0.7px #000000); + border: 1.3px solid #1976d2; + -webkit-filter: grayscale(100%); + filter: grayscale(100%) brightness(150%) contrast(150%) drop-shadow(0.7px 0.7px 0.7px #000000); } .phoneFlippedSmallAvatar:after { content: ''; position: absolute; top: 0; left: 0; bottom: 0; right: 0; + border-radius: 50%; + border: 2.4px solid #1976d2; box-shadow: inset 0px 0px 35px rgb(255, 255, 255); }