fix wallet get_full_history: add onchain tx for channels not opened by us
This commit is contained in:
@@ -804,6 +804,7 @@ class LNWallet(LNWorker):
|
||||
return out
|
||||
|
||||
def get_onchain_history(self):
|
||||
current_height = self.wallet.get_local_height()
|
||||
out = {}
|
||||
# add funding events
|
||||
for chan in self.channels.values():
|
||||
@@ -820,6 +821,8 @@ class LNWallet(LNWorker):
|
||||
'direction': 'received',
|
||||
'timestamp': funding_timestamp,
|
||||
'fee_msat': None,
|
||||
'height': funding_height,
|
||||
'confirmations': max(current_height - funding_height + 1, 0),
|
||||
}
|
||||
out[funding_txid] = item
|
||||
item = chan.get_closing_height()
|
||||
@@ -835,11 +838,12 @@ class LNWallet(LNWorker):
|
||||
'direction': 'sent',
|
||||
'timestamp': closing_timestamp,
|
||||
'fee_msat': None,
|
||||
'height': closing_height,
|
||||
'confirmations': max(current_height - closing_height + 1, 0),
|
||||
}
|
||||
out[closing_txid] = item
|
||||
# add info about submarine swaps
|
||||
settled_payments = self.get_payments(status='settled')
|
||||
current_height = self.wallet.get_local_height()
|
||||
for payment_hash_hex, swap in self.swap_manager.swaps.items():
|
||||
txid = swap.spending_txid if swap.is_reverse else swap.funding_txid
|
||||
if txid is None:
|
||||
|
||||
@@ -903,18 +903,23 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
|
||||
transactions_tmp = OrderedDictWithIndex()
|
||||
# add on-chain txns
|
||||
onchain_history = self.get_onchain_history(domain=onchain_domain)
|
||||
lnworker_history = self.lnworker.get_onchain_history() if self.lnworker and include_lightning else {}
|
||||
for tx_item in onchain_history:
|
||||
txid = tx_item['txid']
|
||||
transactions_tmp[txid] = tx_item
|
||||
# add lnworker info here
|
||||
if txid in lnworker_history:
|
||||
item = lnworker_history[txid]
|
||||
# add lnworker onchain transactions
|
||||
lnworker_history = self.lnworker.get_onchain_history() if self.lnworker and include_lightning else {}
|
||||
for txid, item in lnworker_history.items():
|
||||
if txid in transactions_tmp:
|
||||
tx_item = transactions_tmp[txid]
|
||||
tx_item['group_id'] = item.get('group_id') # for swaps
|
||||
tx_item['label'] = item['label']
|
||||
tx_item['type'] = item['type']
|
||||
ln_value = Decimal(item['amount_msat']) / 1000 # for channel open/close tx
|
||||
tx_item['ln_value'] = Satoshis(ln_value)
|
||||
else:
|
||||
transactions_tmp[txid] = item
|
||||
ln_value = Decimal(item['amount_msat']) / 1000 # for channel open/close tx
|
||||
item['ln_value'] = Satoshis(ln_value)
|
||||
# add lightning_transactions
|
||||
lightning_history = self.lnworker.get_lightning_history() if self.lnworker and include_lightning else {}
|
||||
for tx_item in lightning_history.values():
|
||||
|
||||
Reference in New Issue
Block a user