Skip to content

Commit

Permalink
v1.0.5 (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptosharks131 authored Mar 28, 2022
1 parent 6381abf commit 479a563
Show file tree
Hide file tree
Showing 21 changed files with 577 additions and 94 deletions.
1 change: 1 addition & 0 deletions gui/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class AutoRebalanceForm(forms.Form):
(5, 'ar_enabled'),
(6, 'ar_max_cost'),
(7, 'channel_state'),
(8, 'auto_fees'),
]

class UpdateChannel(forms.Form):
Expand Down
23 changes: 23 additions & 0 deletions gui/migrations/0023_repair_closures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.7 on 2022-03-11 23:31

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

class Migration(migrations.Migration):

dependencies = [
('gui', '0022_auto_20220227_2235'),
]

operations = [
migrations.AddField(
model_name='channels',
name='fees_updated',
field=models.DateTimeField(default=django.utils.timezone.now),
),
migrations.AddField(
model_name='channels',
name='auto_fees',
field=models.BooleanField(default=False),
),
]
26 changes: 26 additions & 0 deletions gui/migrations/0024_autofees.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 3.2.7 on 2022-03-16 17:12

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


class Migration(migrations.Migration):

dependencies = [
('gui', '0023_repair_closures'),
]

operations = [
migrations.CreateModel(
name='Autofees',
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.CharField(max_length=20)),
('peer_alias', models.CharField(max_length=32)),
('setting', models.CharField(max_length=20)),
('old_value', models.IntegerField()),
('new_value', models.IntegerField()),
],
),
]
54 changes: 54 additions & 0 deletions gui/migrations/0025_alter_closures_unique_together.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Generated by Django 3.2.7 on 2022-03-23 14:59

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('gui', '0024_autofees'),
]

operations = [
migrations.DeleteModel(
name='Resolutions',
),
migrations.DeleteModel(
name='Closures',
),
migrations.CreateModel(
name='Resolutions',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('chan_id', models.CharField(max_length=20)),
('resolution_type', models.IntegerField()),
('outcome', models.IntegerField()),
('outpoint_tx', models.CharField(max_length=64)),
('outpoint_index', models.IntegerField()),
('amount_sat', models.BigIntegerField()),
('sweep_txid', models.CharField(max_length=64)),
],
),
migrations.CreateModel(
name='Closures',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('chan_id', models.CharField(max_length=20)),
('funding_txid', models.CharField(max_length=64)),
('funding_index', models.IntegerField()),
('closing_tx', models.CharField(max_length=64)),
('remote_pubkey', models.CharField(max_length=66)),
('capacity', models.BigIntegerField()),
('close_height', models.IntegerField()),
('settled_balance', models.BigIntegerField()),
('time_locked_balance', models.BigIntegerField()),
('close_type', models.IntegerField()),
('open_initiator', models.IntegerField()),
('close_initiator', models.IntegerField()),
('resolution_count', models.IntegerField()),
],
options={
'unique_together': {('funding_txid', 'funding_index')},
},
),
]
19 changes: 17 additions & 2 deletions gui/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class Channels(models.Model):
ar_in_target = models.IntegerField(default=100)
ar_out_target = models.IntegerField()
ar_max_cost = models.IntegerField()
fees_updated = models.DateTimeField(default=timezone.now)
auto_fees = models.BooleanField(default=False)

def save(self, *args, **kwargs):
if not self.ar_out_target:
Expand Down Expand Up @@ -169,7 +171,9 @@ class Meta:
app_label = 'gui'

class Closures(models.Model):
chan_id = models.CharField(max_length=20, primary_key=True)
chan_id = models.CharField(max_length=20)
funding_txid = models.CharField(max_length=64)
funding_index = models.IntegerField()
closing_tx = models.CharField(max_length=64)
remote_pubkey = models.CharField(max_length=66)
capacity = models.BigIntegerField()
Expand All @@ -182,9 +186,10 @@ class Closures(models.Model):
resolution_count = models.IntegerField()
class Meta:
app_label = 'gui'
unique_together = (('funding_txid', 'funding_index'),)

class Resolutions(models.Model):
chan_id = models.ForeignKey('Closures', on_delete=models.CASCADE)
chan_id = models.CharField(max_length=20)
resolution_type = models.IntegerField()
outcome = models.IntegerField()
outpoint_tx = models.CharField(max_length=64)
Expand Down Expand Up @@ -222,6 +227,16 @@ class Meta:
app_label = 'gui'

class Autopilot(models.Model):
timestamp = models.DateTimeField(default=timezone.now)
chan_id = models.CharField(max_length=20)
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'

class Autofees(models.Model):
timestamp = models.DateTimeField(default=timezone.now)
chan_id = models.CharField(max_length=20)
peer_alias = models.CharField(max_length=32)
Expand Down
14 changes: 13 additions & 1 deletion gui/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from rest_framework import serializers
from rest_framework.relations import PrimaryKeyRelatedField
from .models import LocalSettings, Payments, PaymentHops, Invoices, Forwards, Channels, Rebalancer, Peers, Onchain, PendingHTLCs, FailedHTLCs
from .models import LocalSettings, Payments, PaymentHops, Invoices, Forwards, Channels, Rebalancer, Peers, Onchain, PendingHTLCs, FailedHTLCs, Closures, Resolutions

##FUTURE UPDATE 'exclude' TO 'fields'

Expand Down Expand Up @@ -89,6 +89,18 @@ class Meta:
model = Onchain
exclude = []

class ClosuresSerializer(serializers.HyperlinkedModelSerializer):
id = serializers.ReadOnlyField()
class Meta:
model = Closures
exclude = []

class ResolutionsSerializer(serializers.HyperlinkedModelSerializer):
id = serializers.ReadOnlyField()
class Meta:
model = Resolutions
exclude = []

class PaymentHopsSerializer(serializers.HyperlinkedModelSerializer):
payment_hash = PrimaryKeyRelatedField(read_only=True)
class Meta:
Expand Down
56 changes: 55 additions & 1 deletion gui/templates/advanced.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,60 @@
<h2>Advanced Channel Settings</h2>
<div class="w3-container w3-padding-small" style="overflow-x: scroll">
<table class="w3-table-all w3-centered w3-hoverable">
<tr>
<th colspan="7"></th>
<td title="Update all channel outgoing fee rates">
<form action="/update_setting/" method="post">
{% csrf_token %}
<input style="text-align:center" id="value" type="number" min="0" max="100000" name="value" value="">
<input type="hidden" name="key" value="ALL-oRate">
</form>
</td>
<td title="Update all channel outgoing base fees">
<form action="/update_setting/" method="post">
{% csrf_token %}
<input style="text-align:center" id="value" type="number" min="0" max="100000" name="value" value="">
<input type="hidden" name="key" value="ALL-oBase">
</form>
</td>
<th colspan="2"></th>
<td title="Update all channel AR amount amounts">
<form action="/update_setting/" method="post">
{% csrf_token %}
<input style="text-align:center" id="value" type="number" min="0" max="100000000" name="value" value="">
<input type="hidden" name="key" value="ALL-Amts">
</form>
</td>
<td title="Update all channel AR max cost %s">
<form action="/update_setting/" method="post">
{% csrf_token %}
<input style="text-align:center" id="value" type="number" min="0" max="100" name="value" value="">
<input type="hidden" name="key" value="ALL-MaxCost">
</form>
</td>
<td title="Update all channel AR outbound liquidity amount %s">
<form action="/update_setting/" method="post">
{% csrf_token %}
<input style="text-align:center" id="value" type="number" min="0" max="100" name="value" value="">
<input type="hidden" name="key" value="ALL-oTarget">
</form>
</td>
<td title="Update all channel AR inbound liquidity amount %s">
<form action="/update_setting/" method="post">
{% csrf_token %}
<input style="text-align:center" id="value" type="number" min="0" max="100" name="value" value="">
<input type="hidden" name="key" value="ALL-iTarget">
</form>
</td>
<td title="Update all channel AR enable/disable targeting">
<form action="/update_setting/" method="post">
{% csrf_token %}
<input style="text-align:center" id="value" type="number" min="0" max="1" name="value" value="">
<input type="hidden" name="key" value="ALL-AR">
</form>
</td>
<th></th>
</tr>
<tr>
<th>Channel ID</th>
<th>Peer Alias</th>
Expand Down Expand Up @@ -142,7 +196,7 @@ <h2>Update Local Settings</h2>
<input style="text-align:center" id="value" type="number" min="0" max="1" name="value" value="{{ settings.value }}">
{% elif settings.key == 'LND-RetentionDays' %}
<input style="text-align:center" id="value" type="number" min="0" max="1000" name="value" value="{{ settings.value }}">
{% elif settings.key|slice:":3" == 'AR-' %}
{% elif settings.key|slice:":3" == 'AR-' or settings.key|slice:":3" == 'AF-' %}
<input style="text-align:center" id="value" type="number" min="0" max="1" name="value" value="{{ settings.value }}">
{% else %}
<input style="text-align:center" id="value" type="text" name="value" value="{{ settings.value }}">
Expand Down
36 changes: 36 additions & 0 deletions gui/templates/autofees.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{% extends "base.html" %}
{% block title %} {{ block.super }} - Autofees{% endblock %}
{% block content %}
{% load humanize %}
{% if autofees %}
<div class="w3-container w3-padding-small">
<h2>Autofees 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 autofees %}
<tr>
<td title="{{ log.timestamp }}">{{ log.timestamp|naturaltime }}</td>
<td><a href="/channel?={{ log.chan_id }}" target="_blank">{{ log.chan_id }}</a></td>
<td>{% if log.peer_alias == '' %}---{% else %}{{ log.peer_alias }}{% endif %}</td>
<td>{{ log.setting }}</td>
<td>{{ log.old_value }}</td>
<td>{{ log.new_value }}</td>
</tr>
{% endfor %}
</table>
</div>
{% endif %}
{% if not autofees %}
<div class="w3-container w3-padding-small">
<center><h1>No autofees logs to see here yet!</h1></center>
<center><h6>Experimental. This will allow LNDg to automatically act upon the suggestions found <a href="/fees" target="_blank">here</a>.</h6></center>
</div>
{% endif %}
{% endblock %}
2 changes: 1 addition & 1 deletion gui/templates/autopilot.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h2>Autopilot Logs</h2>
</tr>
{% for log in autopilot %}
<tr>
<td>{{ log.timestamp|naturaltime }}</td>
<td title="{{ log.timestamp }}">{{ log.timestamp|naturaltime }}</td>
<td><a href="/channel?={{ log.chan_id }}" target="_blank">{{ log.chan_id }}</a></td>
<td>{% if log.peer_alias == '' %}---{% else %}{{ log.peer_alias }}{% endif %}</td>
<td>{{ log.setting }}</td>
Expand Down
6 changes: 3 additions & 3 deletions gui/templates/balances.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ <h2>Transactions</h2>
{% for transaction in transactions %}
<tr>
<td><a href="{{ network_links }}/{{ network }}tx/{{ transaction.tx_hash }}" target="_blank">{{ transaction.tx_hash }}</a></td>
<td>{{ transaction.amount }}</td>
<td>{% if transaction.block_height == 0 %}{{ transaction.block_height }}{% else %}<a href="{{ network_links }}/{{ network }}block/{{ transaction.block_height }}" target="_blank">{{ transaction.block_height }}</a>{% endif %}</td>
<td>{{ transaction.fee }}</td>
<td>{{ transaction.amount|intcomma }}</td>
<td>{% if transaction.block_height == 0 %}---{% else %}<a href="{{ network_links }}/{{ network }}block/{{ transaction.block_height }}" target="_blank">{{ transaction.block_height|intcomma }}</a>{% endif %}</td>
<td>{{ transaction.fee|intcomma }}</td>
<td>{{ transaction.label }}</td>
</tr>
{% endfor %}
Expand Down
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.4</center>
<center>LNDg v1.0.5</center>
</div>
</div>
</footer>
Expand Down
Loading

0 comments on commit 479a563

Please sign in to comment.