add labels to lightning history
This commit is contained in:
@@ -100,11 +100,7 @@ class InvoiceList(MyTreeView):
|
|||||||
lnaddr = lndecode(invoice, expected_hrp=constants.net.SEGWIT_HRP)
|
lnaddr = lndecode(invoice, expected_hrp=constants.net.SEGWIT_HRP)
|
||||||
amount_sat = lnaddr.amount*COIN if lnaddr.amount else None
|
amount_sat = lnaddr.amount*COIN if lnaddr.amount else None
|
||||||
amount_str = self.parent.format_amount(amount_sat) if amount_sat else ''
|
amount_str = self.parent.format_amount(amount_sat) if amount_sat else ''
|
||||||
description = ''
|
description = lnaddr.get_description()
|
||||||
for k,v in lnaddr.tags:
|
|
||||||
if k == 'd':
|
|
||||||
description = v
|
|
||||||
break
|
|
||||||
date_str = format_time(lnaddr.date)
|
date_str = format_time(lnaddr.date)
|
||||||
labels = [date_str, description, amount_str, pr_tooltips.get(status,'')]
|
labels = [date_str, description, amount_str, pr_tooltips.get(status,'')]
|
||||||
items = [QStandardItem(e) for e in labels]
|
items = [QStandardItem(e) for e in labels]
|
||||||
|
|||||||
@@ -144,11 +144,7 @@ class RequestList(MyTreeView):
|
|||||||
lnaddr = lndecode(invoice, expected_hrp=constants.net.SEGWIT_HRP)
|
lnaddr = lndecode(invoice, expected_hrp=constants.net.SEGWIT_HRP)
|
||||||
amount_sat = lnaddr.amount*COIN if lnaddr.amount else None
|
amount_sat = lnaddr.amount*COIN if lnaddr.amount else None
|
||||||
amount_str = self.parent.format_amount(amount_sat) if amount_sat else ''
|
amount_str = self.parent.format_amount(amount_sat) if amount_sat else ''
|
||||||
description = ''
|
description = lnaddr.get_description()
|
||||||
for k,v in lnaddr.tags:
|
|
||||||
if k == 'd':
|
|
||||||
description = v
|
|
||||||
break
|
|
||||||
date = format_time(lnaddr.date)
|
date = format_time(lnaddr.date)
|
||||||
labels = [date, description, amount_str, pr_tooltips.get(status,'')]
|
labels = [date, description, amount_str, pr_tooltips.get(status,'')]
|
||||||
items = [QStandardItem(e) for e in labels]
|
items = [QStandardItem(e) for e in labels]
|
||||||
|
|||||||
@@ -258,6 +258,14 @@ class LnAddr(object):
|
|||||||
def get_min_final_cltv_expiry(self) -> int:
|
def get_min_final_cltv_expiry(self) -> int:
|
||||||
return self._min_final_cltv_expiry
|
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):
|
def lndecode(a, verbose=False, expected_hrp=None):
|
||||||
if expected_hrp is None:
|
if expected_hrp is None:
|
||||||
|
|||||||
@@ -305,8 +305,8 @@ class LNWallet(LNWorker):
|
|||||||
chan_id, htlc, _direction, status = plist[0]
|
chan_id, htlc, _direction, status = plist[0]
|
||||||
direction = 'sent' if _direction == SENT else 'received'
|
direction = 'sent' if _direction == SENT else 'received'
|
||||||
amount_msat= int(_direction) * htlc.amount_msat
|
amount_msat= int(_direction) * htlc.amount_msat
|
||||||
label = ''
|
|
||||||
timestamp = htlc.timestamp
|
timestamp = htlc.timestamp
|
||||||
|
label = self.get_invoice_label(bfh(payment_hash))
|
||||||
else:
|
else:
|
||||||
# assume forwarding
|
# assume forwarding
|
||||||
direction = 'forwarding'
|
direction = 'forwarding'
|
||||||
@@ -742,6 +742,14 @@ class LNWallet(LNWorker):
|
|||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
raise UnknownPaymentHash(payment_hash) from 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):
|
def _calc_routing_hints_for_invoice(self, amount_sat):
|
||||||
"""calculate routing hints (BOLT-11 'r' field)"""
|
"""calculate routing hints (BOLT-11 'r' field)"""
|
||||||
self.channel_db.load_data()
|
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
|
# 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():
|
for channel_id, chan in self.channels.items():
|
||||||
yield {
|
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])),
|
'remote_htlcs': json.loads(encoder.encode(chan.hm.log[REMOTE])),
|
||||||
'channel_id': bh2u(chan.short_channel_id) if chan.short_channel_id else None,
|
'channel_id': bh2u(chan.short_channel_id) if chan.short_channel_id else None,
|
||||||
'full_channel_id': bh2u(chan.channel_id),
|
'full_channel_id': bh2u(chan.channel_id),
|
||||||
|
|||||||
Reference in New Issue
Block a user