From 4d0c62734cd042f23f6576bfc088c5780dc89b83 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Sun, 23 Jan 2022 13:56:26 -0800 Subject: [PATCH] Add preliminary routing failure frontend components --- api/models.py | 8 +++-- frontend/src/components/TradeBox.js | 52 +++++++++++++++++++++++++++-- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/api/models.py b/api/models.py index e82f0226..c40457d0 100644 --- a/api/models.py +++ b/api/models.py @@ -37,7 +37,7 @@ class Currency(models.Model): class LNPayment(models.Model): class Types(models.IntegerChoices): - NORM = 0, 'Regular invoice' # Only outgoing buyer payment will be a regular invoice (Non-hold) + NORM = 0, 'Regular invoice' HOLD = 1, 'hold invoice' class Concepts(models.IntegerChoices): @@ -62,7 +62,6 @@ class LNPayment(models.Model): type = models.PositiveSmallIntegerField(choices=Types.choices, null=False, default=Types.HOLD) concept = models.PositiveSmallIntegerField(choices=Concepts.choices, null=False, default=Concepts.MAKEBOND) status = models.PositiveSmallIntegerField(choices=Status.choices, null=False, default=Status.INVGEN) - routing_retries = models.PositiveSmallIntegerField(null=False, default=0) # payment info payment_hash = models.CharField(max_length=100, unique=True, default=None, blank=True, primary_key=True) @@ -73,6 +72,10 @@ class LNPayment(models.Model): created_at = models.DateTimeField() expires_at = models.DateTimeField() + # routing + routing_attempts = models.PositiveSmallIntegerField(null=False, default=0) + last_routing_time = models.DateTimeField(null=True, default=None, blank=True) + # involved parties sender = models.ForeignKey(User, related_name='sender', on_delete=models.CASCADE, null=True, default=None) receiver = models.ForeignKey(User, related_name='receiver', on_delete=models.CASCADE, null=True, default=None) @@ -156,7 +159,6 @@ class Order(models.Model): maker_bond = models.OneToOneField(LNPayment, related_name='order_made', on_delete=models.SET_NULL, null=True, default=None, blank=True) taker_bond = models.OneToOneField(LNPayment, related_name='order_taken', on_delete=models.SET_NULL, null=True, default=None, blank=True) trade_escrow = models.OneToOneField(LNPayment, related_name='order_escrow', on_delete=models.SET_NULL, null=True, default=None, blank=True) - # buyer payment LN invoice buyer_invoice = models.OneToOneField(LNPayment, related_name='order_paid', on_delete=models.SET_NULL, null=True, default=None, blank=True) diff --git a/frontend/src/components/TradeBox.js b/frontend/src/components/TradeBox.js index ee1b814d..79f86a2c 100644 --- a/frontend/src/components/TradeBox.js +++ b/frontend/src/components/TradeBox.js @@ -644,6 +644,51 @@ handleRatingChange=(e)=>{ ) } + showSendingPayment(){ + return( + + + + Attempting Lightning Payment + + + + + RoboSats is trying to pay your lightning invoice. Remember that lightning nodes must + be online in order to receive payments. + + + + ) + } + + showRoutingFailed(){ + + // TODO If it has failed 3 times, ask for a new invoice. + + return( + + + + Lightning Routing Failed + + + + + RoboSats will retry pay your invoice 3 times every 5 minutes. If it keeps failing, you + will be able to submit a new invoice. Check whether you have enough inboud liquidity. + Remember that lightning nodes must be online in order to receive payments. + + + + + + + + + ) + } + render() { return ( @@ -672,11 +717,14 @@ handleRatingChange=(e)=>{ {this.props.data.status == 9 || this.props.data.status == 10 ? this.showChat(): ""} {/* Trade Finished */} - {(this.props.data.is_seller & this.props.data.status > 12 & this.props.data.status < 15) ? this.showRateSelect() : ""} + {(this.props.data.is_seller & [13,14,15].includes(this.props.data.status)) ? this.showRateSelect() : ""} {(this.props.data.is_buyer & this.props.data.status == 14) ? this.showRateSelect() : ""} {/* Trade Finished - Payment Routing Failed */} - {this.props.data.is_buyer & this.props.data.status == 15 ? this.showUpdateInvoice() : ""} + {this.props.data.is_buyer & this.props.data.status == 13 ? this.showSendingPayment() : ""} + + {/* Trade Finished - Payment Routing Failed */} + {this.props.data.is_buyer & this.props.data.status == 15 ? this.showRoutingFailed() : ""} {/* Trade Finished - TODO Needs more planning */} {this.props.data.status == 11 ? this.showInDisputeStatement() : ""}