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