mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 20:21:35 +00:00
Add explicit routing failure reasons for users
This commit is contained in:
parent
f7b9ca67d4
commit
d48ee9ced4
@ -255,6 +255,7 @@ class LNNode:
|
|||||||
5 Insufficient local balance.
|
5 Insufficient local balance.
|
||||||
"""
|
"""
|
||||||
failure_reason = cls.payment_failure_context[response.failure_reason]
|
failure_reason = cls.payment_failure_context[response.failure_reason]
|
||||||
|
lnpayment.failure_reason = response.failure_reason
|
||||||
lnpayment.status = LNPayment.Status.FAILRO
|
lnpayment.status = LNPayment.Status.FAILRO
|
||||||
lnpayment.save()
|
lnpayment.save()
|
||||||
return False, failure_reason
|
return False, failure_reason
|
||||||
@ -262,6 +263,7 @@ class LNNode:
|
|||||||
if response.status == 2: # STATUS 'SUCCEEDED'
|
if response.status == 2: # STATUS 'SUCCEEDED'
|
||||||
lnpayment.status = LNPayment.Status.SUCCED
|
lnpayment.status = LNPayment.Status.SUCCED
|
||||||
lnpayment.fee = float(response.fee_msat)/1000
|
lnpayment.fee = float(response.fee_msat)/1000
|
||||||
|
lnpayment.preimage = response.payment_preimage
|
||||||
lnpayment.save()
|
lnpayment.save()
|
||||||
return True, None
|
return True, None
|
||||||
|
|
||||||
|
@ -75,6 +75,14 @@ class LNPayment(models.Model):
|
|||||||
SUCCED = 8, "Succeeded"
|
SUCCED = 8, "Succeeded"
|
||||||
FAILRO = 9, "Routing failed"
|
FAILRO = 9, "Routing failed"
|
||||||
|
|
||||||
|
class FailureReason(models.IntegerChoices):
|
||||||
|
NOTYETF = 0, "Payment isn't failed (yet)"
|
||||||
|
TIMEOUT = 1, "There are more routes to try, but the payment timeout was exceeded."
|
||||||
|
NOROUTE = 2, "All possible routes were tried and failed permanently. Or there were no routes to the destination at all."
|
||||||
|
NONRECO = 3, "A non-recoverable error has occurred."
|
||||||
|
INCORRE = 4, "Payment details are incorrect (unknown hash, invalid amount or invalid final CLTV delta)."
|
||||||
|
NOBALAN = 5, "Insufficient unlocked balance in RoboSats' node."
|
||||||
|
|
||||||
# payment use details
|
# payment use details
|
||||||
type = models.PositiveSmallIntegerField(choices=Types.choices,
|
type = models.PositiveSmallIntegerField(choices=Types.choices,
|
||||||
null=False,
|
null=False,
|
||||||
@ -85,6 +93,9 @@ class LNPayment(models.Model):
|
|||||||
status = models.PositiveSmallIntegerField(choices=Status.choices,
|
status = models.PositiveSmallIntegerField(choices=Status.choices,
|
||||||
null=False,
|
null=False,
|
||||||
default=Status.INVGEN)
|
default=Status.INVGEN)
|
||||||
|
failure_reason = models.PositiveSmallIntegerField(choices=FailureReason.choices,
|
||||||
|
null=True,
|
||||||
|
default=None)
|
||||||
|
|
||||||
# payment info
|
# payment info
|
||||||
payment_hash = models.CharField(max_length=100,
|
payment_hash = models.CharField(max_length=100,
|
||||||
|
@ -115,6 +115,7 @@ def follow_send_payment(hash):
|
|||||||
lnpayment.status = LNPayment.Status.FAILRO
|
lnpayment.status = LNPayment.Status.FAILRO
|
||||||
lnpayment.last_routing_time = timezone.now()
|
lnpayment.last_routing_time = timezone.now()
|
||||||
lnpayment.routing_attempts += 1
|
lnpayment.routing_attempts += 1
|
||||||
|
lnpayment.failure_reason = response.failure_reason
|
||||||
lnpayment.in_flight = False
|
lnpayment.in_flight = False
|
||||||
if lnpayment.routing_attempts > 2:
|
if lnpayment.routing_attempts > 2:
|
||||||
lnpayment.status = LNPayment.Status.EXPIRE
|
lnpayment.status = LNPayment.Status.EXPIRE
|
||||||
@ -140,6 +141,7 @@ def follow_send_payment(hash):
|
|||||||
print("SUCCEEDED")
|
print("SUCCEEDED")
|
||||||
lnpayment.status = LNPayment.Status.SUCCED
|
lnpayment.status = LNPayment.Status.SUCCED
|
||||||
lnpayment.fee = float(response.fee_msat)/1000
|
lnpayment.fee = float(response.fee_msat)/1000
|
||||||
|
lnpayment.preimage = response.payment_preimage
|
||||||
lnpayment.save()
|
lnpayment.save()
|
||||||
order.status = Order.Status.SUC
|
order.status = Order.Status.SUC
|
||||||
order.expires_at = timezone.now() + timedelta(
|
order.expires_at = timezone.now() + timedelta(
|
||||||
|
@ -379,6 +379,8 @@ class OrderView(viewsets.ViewSet):
|
|||||||
data["retries"] = order.payout.routing_attempts
|
data["retries"] = order.payout.routing_attempts
|
||||||
data["next_retry_time"] = order.payout.last_routing_time + timedelta(
|
data["next_retry_time"] = order.payout.last_routing_time + timedelta(
|
||||||
minutes=RETRY_TIME)
|
minutes=RETRY_TIME)
|
||||||
|
if order.payout.failure_reason:
|
||||||
|
data["failure_reason"] = LNPayment.FailureReason(order.payout.failure_reason).label
|
||||||
|
|
||||||
if order.payout.status == LNPayment.Status.EXPIRE:
|
if order.payout.status == LNPayment.Status.EXPIRE:
|
||||||
data["invoice_expired"] = True
|
data["invoice_expired"] = True
|
||||||
|
@ -1159,6 +1159,20 @@ handleRatingRobosatsChange=(e)=>{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
failureReason=()=>{
|
||||||
|
const { t } = this.props;
|
||||||
|
return(
|
||||||
|
<Grid item xs={12} align="center">
|
||||||
|
<Typography variant="body2" align="center">
|
||||||
|
<b>{"Failure reason:"}</b>
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body2" align="center">
|
||||||
|
{t(this.props.data.failure_reason)}
|
||||||
|
</Typography>
|
||||||
|
</Grid>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
showRoutingFailed=()=>{
|
showRoutingFailed=()=>{
|
||||||
const { t } = this.props;
|
const { t } = this.props;
|
||||||
if(this.props.data.invoice_expired){
|
if(this.props.data.invoice_expired){
|
||||||
@ -1172,10 +1186,11 @@ handleRatingRobosatsChange=(e)=>{
|
|||||||
<Grid item xs={12} align="center">
|
<Grid item xs={12} align="center">
|
||||||
<Typography variant="body2" align="center">
|
<Typography variant="body2" align="center">
|
||||||
{t("Your invoice has expired or more than 3 payment attempts have been made.")}
|
{t("Your invoice has expired or more than 3 payment attempts have been made.")}
|
||||||
<Link href="https://github.com/Reckless-Satoshi/robosats/issues/44"> {t("Check the list of compatible wallets")}</Link>
|
|
||||||
</Typography>
|
</Typography>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
{this.props.data.failure_reason ? this.failureReason():null}
|
||||||
|
|
||||||
<Grid item xs={12} align="center">
|
<Grid item xs={12} align="center">
|
||||||
{this.compatibleWalletsButton()}
|
{this.compatibleWalletsButton()}
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -1214,6 +1229,9 @@ handleRatingRobosatsChange=(e)=>{
|
|||||||
{t("Lightning Routing Failed")}
|
{t("Lightning Routing Failed")}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
{this.props.data.failure_reason ? this.failureReason():null}
|
||||||
|
|
||||||
<Grid item xs={12} align="center">
|
<Grid item xs={12} align="center">
|
||||||
<Typography variant="body2" align="center">
|
<Typography variant="body2" align="center">
|
||||||
{t("RoboSats will try to 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 inbound liquidity. Remember that lightning nodes must be online in order to receive payments.")}
|
{t("RoboSats will try to 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 inbound liquidity. Remember that lightning nodes must be online in order to receive payments.")}
|
||||||
|
Loading…
Reference in New Issue
Block a user