Add preliminary routing failure frontend components

This commit is contained in:
Reckless_Satoshi 2022-01-23 13:56:26 -08:00
parent be5b32c451
commit 4d0c62734c
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
2 changed files with 55 additions and 5 deletions

View File

@ -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)

View File

@ -644,6 +644,51 @@ handleRatingChange=(e)=>{
)
}
showSendingPayment(){
return(
<Grid container spacing={1}>
<Grid item xs={12} align="center">
<Typography component="h6" variant="h6">
Attempting Lightning Payment
</Typography>
</Grid>
<Grid item xs={12} align="center">
<Typography component="body2" variant="body2" align="center">
RoboSats is trying to pay your lightning invoice. Remember that lightning nodes must
be online in order to receive payments.
</Typography>
</Grid>
</Grid>
)
}
showRoutingFailed(){
// TODO If it has failed 3 times, ask for a new invoice.
return(
<Grid container spacing={1}>
<Grid item xs={12} align="center">
<Typography component="h6" variant="h6">
Lightning Routing Failed
</Typography>
</Grid>
<Grid item xs={12} align="center">
<Typography component="body2" variant="body2" align="center">
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.
</Typography>
<List>
<ListItemText secondary="Next attempt in">
<Countdown date={new Date(this.props.data.next_retry_time)} renderer={this.countdownRenderer} />
</ListItemText>
</List>
</Grid>
</Grid>
)
}
render() {
return (
<Grid container spacing={1} style={{ width:330}}>
@ -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() : ""}