From 6304e81c525a23248748bf3f10619f925794cf04 Mon Sep 17 00:00:00 2001 From: BhaagBodeDK Date: Thu, 25 Aug 2022 15:51:45 +0000 Subject: [PATCH] #124 Show inflight htlc route --- gui/templates/pending_htlcs.html | 4 ++-- gui/views.py | 11 +++++++++-- jobs.py | 8 ++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/gui/templates/pending_htlcs.html b/gui/templates/pending_htlcs.html index babce0e5..b32b572a 100644 --- a/gui/templates/pending_htlcs.html +++ b/gui/templates/pending_htlcs.html @@ -23,7 +23,7 @@

Outgoing HTLCs

{% if htlc.forwarding_alias == '' %}---{% else %}{{ htlc.forwarding_alias }}{% endif %} {{ htlc.amount|intcomma }} {{ htlc.hours_til_expiration }} hours - {{ htlc.hash_lock }} + {{ htlc.hash_lock }} {% endfor %} @@ -50,7 +50,7 @@

Incoming HTLCs

{% if htlc.forwarding_alias == '' %}---{% else %}{{ htlc.forwarding_alias }}{% endif %} {{ htlc.amount|intcomma }} {{ htlc.hours_til_expiration }} hours - {{ htlc.hash_lock }} + {{ htlc.hash_lock }} {% endfor %} diff --git a/gui/views.py b/gui/views.py index 559c504d..910ba1d8 100644 --- a/gui/views.py +++ b/gui/views.py @@ -1259,7 +1259,14 @@ def channel(request): 'graph_links': graph_links(), 'network_links': network_links() } - return render(request, 'channel.html', context) + try: + return render(request, 'channel.html', context) + except Exception as e: + try: + error = str(e.code()) + except: + error = str(e) + return render(request, 'error.html', {'error': error}) else: return redirect('home') @@ -1369,7 +1376,7 @@ def failed_htlcs(request): def payments(request): if request.method == 'GET': context = { - 'payments': Payments.objects.filter(status=2).annotate(ppm=Round((Sum('fee')*1000000)/Sum('value'), output_field=IntegerField())).order_by('-creation_date')[:150], + 'payments': Payments.objects.exclude(status=3).annotate(ppm=Round((Sum('fee')*1000000)/Sum('value'), output_field=IntegerField())).order_by('-creation_date')[:150], } return render(request, 'payments.html', context) else: diff --git a/jobs.py b/jobs.py index 987099f8..49091015 100644 --- a/jobs.py +++ b/jobs.py @@ -31,9 +31,9 @@ def update_payments(stub): try: new_payment = Payments(creation_date=datetime.fromtimestamp(payment.creation_date), payment_hash=payment.payment_hash, value=round(payment.value_msat/1000, 3), fee=round(payment.fee_msat/1000, 3), status=payment.status, index=payment.payment_index) new_payment.save() - if payment.status == 2: + if payment.status == 2 or payment.status == 1: for attempt in payment.htlcs: - if attempt.status == 1: + if attempt.status == 1 or attempt.status == 0: hops = attempt.route.hops hop_count = 0 cost_to = 0 @@ -74,10 +74,10 @@ def update_payment(stub, payment, self_pubkey): db_payment.status = payment.status db_payment.index = payment.payment_index db_payment.save() - if payment.status == 2: + if payment.status == 2 or payment.status == 1: PaymentHops.objects.filter(payment_hash=db_payment).delete() for attempt in payment.htlcs: - if attempt.status == 1: + if attempt.status == 1 or attempt.status == 0: hops = attempt.route.hops hop_count = 0 cost_to = 0