Skip to content

Commit

Permalink
cryptosharks131#124 Show inflight htlc route
Browse files Browse the repository at this point in the history
  • Loading branch information
BhaagBoseDK committed Aug 27, 2022
1 parent c63c065 commit 6304e81
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions gui/templates/pending_htlcs.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h2>Outgoing HTLCs</h2>
<td>{% if htlc.forwarding_alias == '' %}---{% else %}{{ htlc.forwarding_alias }}{% endif %}</td>
<td>{{ htlc.amount|intcomma }}</td>
<td title="{{ htlc.blocks_til_expiration|intcomma }} blocks to {{ htlc.expiration_height|intcomma }}">{{ htlc.hours_til_expiration }} hours</td>
<td>{{ htlc.hash_lock }}</td>
<td><a href="/route?={{ htlc.hash_lock }}" target="_blank">{{ htlc.hash_lock }}</a></td>
</tr>
{% endfor %}
</table>
Expand All @@ -50,7 +50,7 @@ <h2>Incoming HTLCs</h2>
<td>{% if htlc.forwarding_alias == '' %}---{% else %}{{ htlc.forwarding_alias }}{% endif %}</td>
<td>{{ htlc.amount|intcomma }}</td>
<td title="{{ htlc.blocks_til_expiration|intcomma }} blocks to {{ htlc.expiration_height|intcomma }}">{{ htlc.hours_til_expiration }} hours</td>
<td>{{ htlc.hash_lock }}</td>
<td><a href="/route?={{ htlc.hash_lock }}" target="_blank">{{ htlc.hash_lock }}</a></td>
</tr>
{% endfor %}
</table>
Expand Down
11 changes: 9 additions & 2 deletions gui/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 6304e81

Please sign in to comment.