Skip to content

Commit

Permalink
V1.0.1 (#17)
Browse files Browse the repository at this point in the history
* Suggested Peers Includes Savings By Volume

* Rebalance attempts will no longer be submitted when (your fee * max cost) < peer fee

* Fixes an edge case in the channels data when uptime of a channel is 0 and fee rates never get set

* View keysends page

* Autopilot mode
  • Loading branch information
cryptosharks131 authored Jan 9, 2022
1 parent cc00ec2 commit 03fe7b4
Show file tree
Hide file tree
Showing 14 changed files with 270 additions and 36 deletions.
27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ docker-compose up -d
6. Initialize some settings for your django site (see notes below) `.venv/bin/python initialize.py`
7. The initial login user is `lndg-admin` and the password is output here: `lndg-admin.txt`
8. Generate some initial data for your dashboard `.venv/bin/python jobs.py`
9. Run the server via a python development server `.venv/bin/python manage.py runserver 0.0.0.0:8889`
9. Run the server via a python development server `.venv/bin/python manage.py runserver 0.0.0.0:8889`
Tip: If you plan to only use the development server, you will need to setup whitenoise (see note below).

### Step 2 - Setup Backend Data, Automated Rebalancing and HTLC Stream Data
Expand All @@ -92,16 +92,13 @@ Alternatively, you may also make your own task for these files with your preferr
2. Pull the new files `git pull`
3. Migrate any database changes `.venv/bin/python manage.py migrate`

### Nginx Webserver
If you would like to serve the dashboard at all times, it is recommended to setup a proper production webserver to host the site.
A bash script has been included to help aide in the setup of a nginx webserver. `sudo bash nginx.sh`

### Notes
1. If you are not using the default settings for LND or you would like to run a LND instance on a network other than `mainnet` you can use the correct flags in step 6 (see `initialize.py --help`) or you can edit the variables directly in `lndg/lndg/settings.py`.
2. Some systems have a hard time serving static files (docker/macOs) and installing whitenoise and configuring it can help solve this issue. You can use `initialize.py -wn` to setup whitenoise and install it with `.venv/bin/pip install whitenoise`.
3. If you want to recreate a settings file, delete it from `lndg/lndg/settings.py` and rerun. `initialize.py`
4. If you plan to run this site continuously, consider setting up a proper web server to host it (see Nginx below).
5. You can manage your login credentials from the admin page. Example: `lndg.local/lndg-admin`
6. If you have issues reaching the site, verify the firewall is open on port 8889 where LNDg is running

### Setup lndg initialize.py options
1. `-ip` or `--nodeip` - Accepts only this host IP to serve the LNDg page - default: `*`
Expand All @@ -115,6 +112,9 @@ A bash script has been included to help aide in the setup of a nginx webserver.
9. `-dx` or `--debug` - Setup the django site in debug mode - default: `False`
10. `-pw` or `--adminpw` Setup a custom admin password - default: `Randomized`

### Using A Webserver
You can serve the dashboard at all times using a webserver instead of the development server. Using a webserver will serve your static files and installing whitenoise is not required when running in this manner. Any webserver can be used to host the site if configured properly. A bash script has been included to help aide in the setup of a nginx webserver. `sudo bash nginx.sh`

## Key Features
### API Backend
The following data can be accessed at the /api endpoint:
Expand Down Expand Up @@ -179,17 +179,22 @@ If you want a channel not to be picked for rebalancing (i.e. it is already full

## Preview Screens
### Main Dashboard
![image](https://user-images.githubusercontent.com/38626122/139308280-13b14393-c5f0-4e2a-8acc-9d87f5c83684.png)
![image](https://user-images.githubusercontent.com/38626122/137809328-c64c038b-8dbb-40a2-aeb3-a1bae5554d7a.png)
![image](https://user-images.githubusercontent.com/38626122/137809356-ec46193a-478c-424b-a184-2b15cfbb5c52.png)
![image](https://user-images.githubusercontent.com/38626122/137809433-b363fff1-31b6-4b0e-80e9-1916ef0af052.png)
![image](https://user-images.githubusercontent.com/38626122/137809648-bb191ba9-b989-4325-95ac-d25a8333ae62.png)
![image](https://user-images.githubusercontent.com/38626122/148699177-d10d412e-641e-4676-acac-2047e7e2d7a6.png)
![image](https://user-images.githubusercontent.com/38626122/148699209-667936fd-c56f-484f-8dd4-75e052c8c14f.png)
![image](https://user-images.githubusercontent.com/38626122/148699224-efb70fcf-0b7e-45cf-bd98-de833b2cff88.png)
![image](https://user-images.githubusercontent.com/38626122/148699273-be470d86-e76c-4935-8337-2b9737aed73e.png)
![image](https://user-images.githubusercontent.com/38626122/148699286-0b1d2c13-191a-4c6c-99ae-ce3d8b8ac64d.png)
![image](https://user-images.githubusercontent.com/38626122/137809583-db743233-25c1-4d3e-aaec-2a7767de2c9f.png)

### Peers, Balances, Routes and Pending HTLCs All Open In Separate Screens
### Peers, Balances, Routes, Keysends and Pending HTLCs All Open In Separate Screens
![image](https://user-images.githubusercontent.com/38626122/137809809-1ed40cfb-9d12-447a-8e5e-82ae79605895.png)
![image](https://user-images.githubusercontent.com/38626122/137810021-4f69dcb0-5fce-4062-bc49-e75f5dd0feda.png)
![image](https://user-images.githubusercontent.com/38626122/137809882-4a87f86d-290c-456e-9606-ed669fd98561.png)
![image](https://user-images.githubusercontent.com/38626122/148699417-bd9fbb49-72f5-4c3f-811f-e18c990a06ba.png)

### Suggests Peers To Open With and Rebalancer Actions To Take
![image](https://user-images.githubusercontent.com/38626122/148699445-88efeacd-3cfc-429c-91d8-3a52ee633195.png)
![image](https://user-images.githubusercontent.com/38626122/148699467-62ebbd7d-9f36-4707-88fd-62f2cc2a5506.png)

### Browsable API at `/api` (json format available with url appended with `?format=json`)
![image](https://user-images.githubusercontent.com/38626122/137810278-7f38ac5b-8932-4953-aa4c-9c29d66dce0c.png)
Expand Down
42 changes: 42 additions & 0 deletions gui/migrations/0016_auto_20220106_1026.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Generated by Django 3.2.7 on 2022-01-06 10:26

from django.db import migrations, models

def update_cost_to(apps, schedma_editor):
payments = apps.get_model('gui', 'payments')
hops = apps.get_model('gui', 'paymenthops')
for payment in payments.objects.filter(status=2).iterator():
cost_to = 0
for hop in hops.objects.filter(payment_hash=payment.payment_hash).order_by('step'):
hop.cost_to = round(cost_to, 3)
hop.save()
cost_to += hop.fee

def revert_cost_to(apps, schedma_editor):
pass

class Migration(migrations.Migration):

dependencies = [
('gui', '0015_invoices_index'),
]

operations = [
migrations.AddField(
model_name='channels',
name='num_updates',
field=models.IntegerField(default=0),
preserve_default=False,
),
migrations.AddField(
model_name='paymenthops',
name='cost_to',
field=models.FloatField(default=0),
),
migrations.RunPython(update_cost_to, revert_cost_to),
migrations.AlterField(
model_name='paymenthops',
name='cost_to',
field=models.FloatField(),
),
]
26 changes: 26 additions & 0 deletions gui/migrations/0017_autopilot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 3.2.7 on 2022-01-06 20:37

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

dependencies = [
('gui', '0016_auto_20220106_1026'),
]

operations = [
migrations.CreateModel(
name='Autopilot',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('timestamp', models.DateTimeField(default=django.utils.timezone.now)),
('chan_id', models.IntegerField()),
('peer_alias', models.CharField(max_length=32)),
('setting', models.CharField(max_length=20)),
('old_value', models.IntegerField()),
('new_value', models.IntegerField()),
],
),
]
12 changes: 12 additions & 0 deletions gui/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class PaymentHops(models.Model):
node_pubkey = models.CharField(max_length=66)
amt = models.FloatField()
fee = models.FloatField()
cost_to = models.FloatField()
class Meta:
app_label = 'gui'
unique_together = (('payment_hash', 'attempt_id', 'step'),)
Expand Down Expand Up @@ -68,6 +69,7 @@ class Channels(models.Model):
unsettled_balance = models.BigIntegerField()
local_commit = models.IntegerField()
local_chan_reserve = models.IntegerField()
num_updates = models.IntegerField()
initiator = models.BooleanField()
alias = models.CharField(max_length=32)
local_base_fee = models.IntegerField()
Expand Down Expand Up @@ -146,5 +148,15 @@ class FailedHTLCs(models.Model):
wire_failure = models.IntegerField()
failure_detail = models.IntegerField()
missed_fee = models.FloatField()
class Meta:
app_label = 'gui'

class Autopilot(models.Model):
timestamp = models.DateTimeField(default=timezone.now)
chan_id = models.IntegerField()
peer_alias = models.CharField(max_length=32)
setting = models.CharField(max_length=20)
old_value = models.IntegerField()
new_value = models.IntegerField()
class Meta:
app_label = 'gui'
35 changes: 35 additions & 0 deletions gui/templates/autopilot.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% extends "base.html" %}
{% block content %}
{% load humanize %}
{% if autopilot %}
<div class="w3-container w3-padding-small">
<h2>Autopilot Logs</h2>
<table class="w3-table-all w3-centered w3-hoverable">
<tr>
<th>Timestamp</th>
<th>Channel ID</th>
<th>Peer Alias</th>
<th>Setting</th>
<th>Old Value</th>
<th>New Value</th>
</tr>
{% for log in autopilot %}
<tr>
<td>{{ log.timestamp|naturaltime }}</a></td>
<td>{{ log.chan_id }}</a></td>
<td>{{ log.peer_alias }}</td>
<td>{{ log.setting }}</td>
<td>{{ log.old_value }}</td>
<td>{{ log.new_value }}</td>
</tr>
{% endfor %}
</table>
</div>
{% endif %}
{% if not autopilot %}
<div class="w3-container w3-padding-small">
<center><h1>No autopilot logs to see here yet!</h1></center>
<center><h6>Experimental. Advanced users may activate via api.</h6></center>
</div>
{% endif %}
{% endblock %}
2 changes: 1 addition & 1 deletion gui/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ <h1><a href="/">My Lnd Overview</a></h1>
<footer>
<div id="footer">
<div class="w3-container w3-padding-small">
<center>LNDg v1.0.0</center>
<center>LNDg v1.0.1</center>
</div>
</div>
</footer>
Expand Down
7 changes: 4 additions & 3 deletions gui/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
{% load humanize %}
<div class="w3-container w3-padding-small">
<h3><a href="https://1ml.com/{{ network }}node/{{ node_info.identity_pubkey }}" target="_blank">{{ node_info.alias }}</a> | {{ node_info.identity_pubkey }}</h3>
<h4>Capacity: {{ capacity|intcomma }} | Active Channels: {{ node_info.num_active_channels }} | <a href="/peers" target="_blank">Peers</a>: {{ node_info.num_peers }} | {% for info in node_info.chains %}{{ info }}{% endfor %} | {{ node_info.block_height }} | {{ node_info.block_hash }}</h4>
<h4>Capacity: {{ capacity|intcomma }} | Active Channels: {{ node_info.num_active_channels }} / {{ total_channels }} | <a href="/peers" target="_blank">Peers</a>: {{ node_info.num_peers }} | DB Size: {{ db_size }} GB</h4>
<h4>Public Address: {% for info in node_info.uris %}{{ info }} | {% endfor %}</h4>
<h4>Lnd sync: {{ node_info.synced_to_graph }} | chain sync: {{ node_info.synced_to_chain }} | {% for info in node_info.chains %}{{ info }}{% endfor %} | {{ node_info.block_height }} | {{ node_info.block_hash }}</h4>
</div>
<div class="w3-container w3-padding-small">
<h4>Wallet Balance: {{ balances.total_balance|intcomma }} | Confirmed Wallet Balance: {{ balances.confirmed_balance|intcomma }} | Unconfirmed Wallet Balance: {{ balances.unconfirmed_balance|intcomma }} | <a href="/balances" target="_blank">Details</a></h4>
Expand All @@ -22,7 +23,7 @@ <h4>7-Day Routed: {{ routed_7day|intcomma }} | Value: {{ routed_7day_amt|intcomm
<div class="w3-container w3-padding-small">
<h4>Inbound Liquidity: {{ inbound|intcomma }} | Outbound Liquidity: {{ outbound|intcomma }} | Liquidity Ratio: {{ liq_ratio }}%</h4>
<h4>Balance In Limbo: {{ limbo_balance|intcomma }} | Unsettled Liquidity: {{ unsettled|intcomma }} | <a href="/pending_htlcs" target="_blank">Pending HTLCs</a>: {{ pending_htlc_count }}</h4>
<h4><a href="/suggested_opens" target="_blank">Suggested New Peers</a> | <a href="/suggested_actions" target="_blank">Suggested AR Actions</a></h4>
<h4><a href="/suggested_opens" target="_blank">Suggested New Peers</a> | <a href="/suggested_actions" target="_blank">Suggested AR Actions</a> | <a href="/autopilot" target="_blank">Autopilot Logs</a></h4>
</div>
{% if active_channels %}
<div class="w3-container w3-padding-small">
Expand Down Expand Up @@ -386,7 +387,7 @@ <h2>Last 5 Payments Received</h2>
<th>State</th>
<th>Channel In Alias</th>
<th width=10%>Channel In</th>
<th>Keysend</th>
<th><a href="/keysends" target="_blank">Keysend</a></th>
</tr>
{% for invoice in invoices %}
<tr>
Expand Down
30 changes: 30 additions & 0 deletions gui/templates/keysends.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% extends "base.html" %}
{% block content %}
{% load humanize %}
{% if keysends %}
<div class="w3-container w3-padding-small">
<h2>Received Keysends</h2>
<table class="w3-table-all w3-centered w3-hoverable">
<tr>
<th>Settle Date</th>
<th>Channel In Alias</th>
<th>Amount</th>
<th>Message</th>
</tr>
{% for keysend in keysends %}
<tr>
<td title="{{ keysend.r_hash }}">{{ keysend.settle_date|naturaltime }}</td>
<td>{{ keysend.chan_in_alias }}</td>
<td>{{ keysend.amt_paid|intcomma }}</td>
<td>{{ keysend.message }}</td>
</tr>
{% endfor %}
</table>
</div>
{% endif %}
{% if not keysends %}
<div class="w3-container w3-padding-small">
<center><h1>You dont have any keysend messages here yet!</h1></center>
</div>
{% endif %}
{% endblock %}
2 changes: 2 additions & 0 deletions gui/templates/open_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ <h2>Suggested Open List</h2>
<th width=12%>Fees Paid</th>
<th width=12%>Effective PPM</th>
<th width=12%>Volume Score</th>
<th width=12%>Savings By Volume</th>
</tr>
{% for node in open_list %}
<tr>
Expand All @@ -23,6 +24,7 @@ <h2>Suggested Open List</h2>
<td>{{ node.fees|add:"0"|intcomma }}</td>
<td>{{ node.ppm|add:"0"|intcomma }}</td>
<td>{{ node.score }}</td>
<td>{{ node.sum_cost_to|add:"0"|intcomma }}</td>
</tr>
{% endfor %}
</table>
Expand Down
2 changes: 2 additions & 0 deletions gui/templates/route.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ <h2>Route For Payment: {{ payment_hash }}</h2>
<th>Alias</th>
<th>Channel ID</th>
<th>Channel Capacity</th>
<th>Cost To</th>
</tr>
{% for hop in route %}
<tr>
Expand All @@ -20,6 +21,7 @@ <h2>Route For Payment: {{ payment_hash }}</h2>
<td>{{ hop.alias }}</td>
<td>{{ hop.chan_id }}</td>
<td>{{ hop.chan_capacity|intcomma }}</td>
<td>{{ hop.cost_to }}</td>
</tr>
{% endfor %}
</table>
Expand Down
4 changes: 3 additions & 1 deletion gui/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
path('ar_target/', views.ar_target, name='ar-target'),
path('suggested_opens/', views.suggested_opens, name='suggested-opens'),
path('suggested_actions/', views.suggested_actions, name='suggested-actions'),
path('keysends/', views.keysends, name='keysends'),
path('autopilot/', views.autopilot, name='autopilot'),
path('api/', include(router.urls), name='api-root'),
path('api-auth/', include('rest_framework.urls'), name='api-auth'),
path('api/connectpeer/', views.connect_peer, name='connect-peer'),
Expand All @@ -42,4 +44,4 @@
path('api/newaddress/', views.new_address, name='new-address'),
path('api/updatealias/', views.update_alias, name='update-alias'),
path('lndg-admin/', admin.site.urls),
]
]
Loading

0 comments on commit 03fe7b4

Please sign in to comment.