mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 17:31:36 +00:00
add labels to lightning history
This commit is contained in:
parent
c4081284bd
commit
e53ecb9b77
4 changed files with 20 additions and 12 deletions
|
@ -100,11 +100,7 @@ class InvoiceList(MyTreeView):
|
|||
lnaddr = lndecode(invoice, expected_hrp=constants.net.SEGWIT_HRP)
|
||||
amount_sat = lnaddr.amount*COIN if lnaddr.amount else None
|
||||
amount_str = self.parent.format_amount(amount_sat) if amount_sat else ''
|
||||
description = ''
|
||||
for k,v in lnaddr.tags:
|
||||
if k == 'd':
|
||||
description = v
|
||||
break
|
||||
description = lnaddr.get_description()
|
||||
date_str = format_time(lnaddr.date)
|
||||
labels = [date_str, description, amount_str, pr_tooltips.get(status,'')]
|
||||
items = [QStandardItem(e) for e in labels]
|
||||
|
|
|
@ -144,11 +144,7 @@ class RequestList(MyTreeView):
|
|||
lnaddr = lndecode(invoice, expected_hrp=constants.net.SEGWIT_HRP)
|
||||
amount_sat = lnaddr.amount*COIN if lnaddr.amount else None
|
||||
amount_str = self.parent.format_amount(amount_sat) if amount_sat else ''
|
||||
description = ''
|
||||
for k,v in lnaddr.tags:
|
||||
if k == 'd':
|
||||
description = v
|
||||
break
|
||||
description = lnaddr.get_description()
|
||||
date = format_time(lnaddr.date)
|
||||
labels = [date, description, amount_str, pr_tooltips.get(status,'')]
|
||||
items = [QStandardItem(e) for e in labels]
|
||||
|
|
|
@ -258,6 +258,14 @@ class LnAddr(object):
|
|||
def get_min_final_cltv_expiry(self) -> int:
|
||||
return self._min_final_cltv_expiry
|
||||
|
||||
def get_description(self):
|
||||
description = ''
|
||||
for k,v in self.tags:
|
||||
if k == 'd':
|
||||
description = v
|
||||
break
|
||||
return description
|
||||
|
||||
|
||||
def lndecode(a, verbose=False, expected_hrp=None):
|
||||
if expected_hrp is None:
|
||||
|
|
|
@ -305,8 +305,8 @@ class LNWallet(LNWorker):
|
|||
chan_id, htlc, _direction, status = plist[0]
|
||||
direction = 'sent' if _direction == SENT else 'received'
|
||||
amount_msat= int(_direction) * htlc.amount_msat
|
||||
label = ''
|
||||
timestamp = htlc.timestamp
|
||||
label = self.get_invoice_label(bfh(payment_hash))
|
||||
else:
|
||||
# assume forwarding
|
||||
direction = 'forwarding'
|
||||
|
@ -742,6 +742,14 @@ class LNWallet(LNWorker):
|
|||
except KeyError as e:
|
||||
raise UnknownPaymentHash(payment_hash) from e
|
||||
|
||||
def get_invoice_label(self, payment_hash: bytes) -> str:
|
||||
try:
|
||||
lnaddr = self.get_invoice(payment_hash)
|
||||
label = lnaddr.get_description()
|
||||
except:
|
||||
label = ''
|
||||
return label
|
||||
|
||||
def _calc_routing_hints_for_invoice(self, amount_sat):
|
||||
"""calculate routing hints (BOLT-11 'r' field)"""
|
||||
self.channel_db.load_data()
|
||||
|
@ -800,7 +808,7 @@ class LNWallet(LNWorker):
|
|||
# we output the funding_outpoint instead of the channel_id because lnd uses channel_point (funding outpoint) to identify channels
|
||||
for channel_id, chan in self.channels.items():
|
||||
yield {
|
||||
'local_htlcs': json.loads(encoder.encode(chan.hm.log[LOCAL ])),
|
||||
'local_htlcs': json.loads(encoder.encode(chan.hm.log[LOCAL])),
|
||||
'remote_htlcs': json.loads(encoder.encode(chan.hm.log[REMOTE])),
|
||||
'channel_id': bh2u(chan.short_channel_id) if chan.short_channel_id else None,
|
||||
'full_channel_id': bh2u(chan.channel_id),
|
||||
|
|
Loading…
Add table
Reference in a new issue