mirror of
https://github.com/mynodebtc/mynode.git
synced 2025-01-11 19:30:11 +00:00
Add TXs to Lightning page
This commit is contained in:
parent
97d96efd09
commit
54cfeb2650
|
@ -5,6 +5,7 @@ import os
|
||||||
import time
|
import time
|
||||||
import re
|
import re
|
||||||
import datetime
|
import datetime
|
||||||
|
import urllib
|
||||||
from flask import current_app as app
|
from flask import current_app as app
|
||||||
from threading import Timer
|
from threading import Timer
|
||||||
from utilities import *
|
from utilities import *
|
||||||
|
@ -23,6 +24,9 @@ lightning_peer_aliases = {}
|
||||||
lightning_channels = None
|
lightning_channels = None
|
||||||
lightning_channel_balance = None
|
lightning_channel_balance = None
|
||||||
lightning_wallet_balance = None
|
lightning_wallet_balance = None
|
||||||
|
lightning_transactions = None
|
||||||
|
lightning_payments = None
|
||||||
|
lightning_invoices = None
|
||||||
lightning_watchtower_server_info = None
|
lightning_watchtower_server_info = None
|
||||||
lightning_desync_count = 0
|
lightning_desync_count = 0
|
||||||
|
|
||||||
|
@ -37,6 +41,9 @@ def update_lightning_info():
|
||||||
global lightning_channels
|
global lightning_channels
|
||||||
global lightning_channel_balance
|
global lightning_channel_balance
|
||||||
global lightning_wallet_balance
|
global lightning_wallet_balance
|
||||||
|
global lightning_transactions
|
||||||
|
global lightning_payments
|
||||||
|
global lightning_invoices
|
||||||
global lightning_watchtower_server_info
|
global lightning_watchtower_server_info
|
||||||
global lightning_desync_count
|
global lightning_desync_count
|
||||||
global lnd_ready
|
global lnd_ready
|
||||||
|
@ -69,10 +76,22 @@ def update_lightning_info():
|
||||||
lightning_channels = lnd_get("/channels")
|
lightning_channels = lnd_get("/channels")
|
||||||
lightning_channel_balance = lnd_get("/balance/channels")
|
lightning_channel_balance = lnd_get("/balance/channels")
|
||||||
lightning_wallet_balance = lnd_get("/balance/blockchain")
|
lightning_wallet_balance = lnd_get("/balance/blockchain")
|
||||||
|
#lightning_transactions = lnd_get("/transactions")
|
||||||
|
#lightning_payments = lnd_get("/payments")
|
||||||
|
#lightning_invoices = lnd_get("/invoices")
|
||||||
lightning_watchtower_server_info = lnd_get_v2("/watchtower/server")
|
lightning_watchtower_server_info = lnd_get_v2("/watchtower/server")
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def update_lightning_tx_info():
|
||||||
|
global lightning_transactions
|
||||||
|
global lightning_payments
|
||||||
|
global lightning_invoices
|
||||||
|
if is_lnd_ready():
|
||||||
|
tx_cache_limit = 50
|
||||||
|
lightning_transactions = lnd_get("/transactions")
|
||||||
|
lightning_payments = lnd_get("/payments", params={"reversed":"true", "index_offset": "0", "max_payments": tx_cache_limit})
|
||||||
|
lightning_invoices = lnd_get("/invoices", params={"reversed":"true", "index_offset": "0", "num_max_invoices": tx_cache_limit})
|
||||||
|
|
||||||
def get_lnd_deposit_address():
|
def get_lnd_deposit_address():
|
||||||
if os.path.isfile("/tmp/lnd_deposit_address"):
|
if os.path.isfile("/tmp/lnd_deposit_address"):
|
||||||
|
@ -230,6 +249,49 @@ def get_lightning_balance_info():
|
||||||
|
|
||||||
return balance_data
|
return balance_data
|
||||||
|
|
||||||
|
def get_lightning_transactions():
|
||||||
|
global lightning_transactions
|
||||||
|
try:
|
||||||
|
transactions = []
|
||||||
|
data = copy.deepcopy(lightning_transactions)
|
||||||
|
for tx in data["transactions"]:
|
||||||
|
tx["amount_str"] = format_sat_amount(tx["amount"])
|
||||||
|
tx["date_str"] = time.strftime("%D %H:%M", time.localtime(int(tx["time_stamp"])))
|
||||||
|
transactions.append(tx)
|
||||||
|
return transactions
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_lightning_payments():
|
||||||
|
global lightning_payments
|
||||||
|
try:
|
||||||
|
payments = []
|
||||||
|
data = copy.deepcopy(lightning_payments)
|
||||||
|
for tx in data["payments"]:
|
||||||
|
tx["value_str"] = format_sat_amount(tx["value_sat"])
|
||||||
|
tx["fee_str"] = format_sat_amount(tx["fee"])
|
||||||
|
tx["date_str"] = time.strftime("%D %H:%M", time.localtime(int(tx["creation_date"])))
|
||||||
|
payments.append(tx)
|
||||||
|
payments.reverse()
|
||||||
|
return payments
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_lightning_invoices():
|
||||||
|
global lightning_invoices
|
||||||
|
try:
|
||||||
|
invoices = []
|
||||||
|
data = copy.deepcopy(lightning_invoices)
|
||||||
|
for tx in data["invoices"]:
|
||||||
|
tx["value_str"] = format_sat_amount(tx["value"])
|
||||||
|
tx["date_str"] = time.strftime("%D %H:%M", time.localtime(int(tx["creation_date"])))
|
||||||
|
tx["memo"] = urllib.unquote_plus(tx["memo"])
|
||||||
|
invoices.append(tx)
|
||||||
|
invoices.reverse()
|
||||||
|
return invoices
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
def get_lightning_watchtower_server_info():
|
def get_lightning_watchtower_server_info():
|
||||||
global lightning_watchtower_server_info
|
global lightning_watchtower_server_info
|
||||||
return copy.deepcopy(lightning_watchtower_server_info)
|
return copy.deepcopy(lightning_watchtower_server_info)
|
||||||
|
@ -238,11 +300,11 @@ def is_lnd_ready():
|
||||||
global lnd_ready
|
global lnd_ready
|
||||||
return lnd_ready
|
return lnd_ready
|
||||||
|
|
||||||
def lnd_get(path, timeout=10):
|
def lnd_get(path, timeout=10, params={}):
|
||||||
try:
|
try:
|
||||||
macaroon = get_macaroon()
|
macaroon = get_macaroon()
|
||||||
headers = {"Grpc-Metadata-macaroon":macaroon}
|
headers = {"Grpc-Metadata-macaroon":macaroon}
|
||||||
r = requests.get("https://localhost:"+LND_REST_PORT+"/v1"+path, verify=TLS_CERT_FILE,headers=headers, timeout=timeout)
|
r = requests.get("https://localhost:"+LND_REST_PORT+"/v1"+path, verify=TLS_CERT_FILE,headers=headers, params=params, timeout=timeout)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
app.logger.info("ERROR in lnd_get: "+str(e))
|
app.logger.info("ERROR in lnd_get: "+str(e))
|
||||||
return {"error": str(e)}
|
return {"error": str(e)}
|
||||||
|
|
|
@ -133,6 +133,12 @@ def page_lnd():
|
||||||
if wallet_balance_data != None and "unconfirmed_balance" in wallet_balance_data:
|
if wallet_balance_data != None and "unconfirmed_balance" in wallet_balance_data:
|
||||||
wallet_pending = wallet_balance_data["unconfirmed_balance"]
|
wallet_pending = wallet_balance_data["unconfirmed_balance"]
|
||||||
|
|
||||||
|
# Update TX info
|
||||||
|
update_lightning_tx_info()
|
||||||
|
transactions = get_lightning_transactions()
|
||||||
|
payments = get_lightning_payments()
|
||||||
|
invoices = get_lightning_invoices()
|
||||||
|
|
||||||
watchtower_server_info = get_lightning_watchtower_server_info()
|
watchtower_server_info = get_lightning_watchtower_server_info()
|
||||||
watchtower_uri = "..."
|
watchtower_uri = "..."
|
||||||
if watchtower_server_info != None:
|
if watchtower_server_info != None:
|
||||||
|
@ -179,6 +185,10 @@ def page_lnd():
|
||||||
"watchtower_uri": watchtower_uri,
|
"watchtower_uri": watchtower_uri,
|
||||||
"peers": peers,
|
"peers": peers,
|
||||||
"channels": channels,
|
"channels": channels,
|
||||||
|
"transactions": transactions,
|
||||||
|
"payments": payments,
|
||||||
|
"invoices": invoices,
|
||||||
|
"tx_display_limit": 8,
|
||||||
"ui_settings": read_ui_settings()
|
"ui_settings": read_ui_settings()
|
||||||
}
|
}
|
||||||
return render_template('lnd.html', **templateData)
|
return render_template('lnd.html', **templateData)
|
||||||
|
|
BIN
rootfs/standard/var/www/mynode/static/images/memo.png
Normal file
BIN
rootfs/standard/var/www/mynode/static/images/memo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.9 KiB |
|
@ -8,6 +8,8 @@
|
||||||
|
|
||||||
alias="{{alias}}"
|
alias="{{alias}}"
|
||||||
|
|
||||||
|
$( document ).tooltip();
|
||||||
|
|
||||||
function change_alias() {
|
function change_alias() {
|
||||||
$("#change_alias_form").submit();
|
$("#change_alias_form").submit();
|
||||||
change_alias_dialog.dialog( "close" );
|
change_alias_dialog.dialog( "close" );
|
||||||
|
@ -373,6 +375,94 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<div class="main_header">Recent Transactions</div>
|
||||||
|
<div class="app_tile_row">
|
||||||
|
{% if transactions and transactions|length > 0 %}
|
||||||
|
<table style="font-size: 12px; width: 300px; margin: 10px;" class="bitcoin_table">
|
||||||
|
<thead class="bitcoin_table_header">
|
||||||
|
<td colspan=9 style="text-align: center;">On-chain TX</td>
|
||||||
|
</thead>
|
||||||
|
<thead class="bitcoin_table_header">
|
||||||
|
<td>Date</td>
|
||||||
|
<td>Amount</td>
|
||||||
|
<td>Confirmations</td>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for tx in transactions[:tx_display_limit] %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ tx.date_str }}</td>
|
||||||
|
<td>{{ tx.amount_str }}</td>
|
||||||
|
<td>{{ tx.num_confirmations }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
{% if transactions|length >= tx_display_limit %}
|
||||||
|
<td colspan=9>more...</td>
|
||||||
|
{% endif %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if payments and payments|length > 0 %}
|
||||||
|
<table style="font-size: 12px; width: 300px; margin: 10px;" class="bitcoin_table">
|
||||||
|
<thead class="bitcoin_table_header">
|
||||||
|
<td colspan=9 style="text-align: center;">Payments</td>
|
||||||
|
</thead>
|
||||||
|
<thead class="bitcoin_table_header">
|
||||||
|
<td>Date</td>
|
||||||
|
<td>Amount</td>
|
||||||
|
<td>Fee</td>
|
||||||
|
<!--<td>Status</td>-->
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for tx in payments[:tx_display_limit] %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ tx.date_str }}</td>
|
||||||
|
<td>{{ tx.value_str }}</td>
|
||||||
|
<td>{{ tx.fee_str }}</td>
|
||||||
|
<!--<td>{{ tx.status }}</td>-->
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
{% if payments|length >= tx_display_limit %}
|
||||||
|
<td colspan=9>more...</td>
|
||||||
|
{% endif %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if invoices and invoices|length > 0 %}
|
||||||
|
<table style="font-size: 12px; width: 300px; margin: 10px;" class="bitcoin_table">
|
||||||
|
<thead class="bitcoin_table_header">
|
||||||
|
<td colspan=9 style="text-align: center;">Invoices</td>
|
||||||
|
</thead>
|
||||||
|
<thead class="bitcoin_table_header">
|
||||||
|
<td>Date</td>
|
||||||
|
<td>Amount</td>
|
||||||
|
<td>Memo</td>
|
||||||
|
<td>State</td>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for tx in invoices[:tx_display_limit] %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ tx.date_str }}</td>
|
||||||
|
<td>{{ tx.value_str }}</td>
|
||||||
|
<td>
|
||||||
|
{% if tx.memo != "" %}
|
||||||
|
<img style="width: 16px;" src="{{ url_for('static', filename="images/memo.png")}}" title="{{ tx.memo }}"/>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>{{ tx.state }}</td>
|
||||||
|
</tr>
|
||||||
|
{% if invoices|length >= tx_display_limit %}
|
||||||
|
<td colspan=9>more...</td>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
<div class="main_header">Channels</div>
|
<div class="main_header">Channels</div>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user