mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-13 10:56:24 +00:00
Improve response time of confirm fiat receive; improve failure routing handling
This commit is contained in:
parent
b39529d91e
commit
3f6731d3e0
@ -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:
|
||||
##### !!! 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, context
|
||||
else:
|
||||
# error handling here
|
||||
return False, context
|
||||
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'}
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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'
|
||||
|
@ -227,11 +227,9 @@ export default class BookPage extends Component {
|
||||
render() {
|
||||
return (
|
||||
<Grid className='orderBook' container spacing={1} sx={{minWidth:400}}>
|
||||
<Grid item xs={12} align="center">
|
||||
<Typography component="h2" variant="h2">
|
||||
Order Book
|
||||
</Typography>
|
||||
</Grid>
|
||||
{/* <Grid item xs={12} align="center">
|
||||
<Typography component="h4" variant="h4">ORDER BOOK</Typography>
|
||||
</Grid> */}
|
||||
|
||||
<Grid item xs={6} align="right">
|
||||
<FormControl >
|
||||
|
@ -153,12 +153,12 @@ export default class MakerPage extends Component {
|
||||
|
||||
render() {
|
||||
return (
|
||||
<Grid container xs={12} align="center" spacing={1}>
|
||||
<Grid item xs={12} align="center" sx={{minWidth:380}}>
|
||||
<Typography component="h2" variant="h2">
|
||||
Order Maker
|
||||
<Grid container xs={12} align="center" spacing={1} sx={{minWidth:380}}>
|
||||
{/* <Grid item xs={12} align="center" sx={{minWidth:380}}>
|
||||
<Typography component="h4" variant="h4">
|
||||
ORDER MAKER
|
||||
</Typography>
|
||||
</Grid>
|
||||
</Grid> */}
|
||||
<Grid item xs={12} align="center" spacing={1}>
|
||||
<Paper elevation={12} style={{ padding: 8, width:240, align:'center'}}>
|
||||
<Grid item xs={12} align="center" spacing={1}>
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user