electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 90b228de839d6474f6d23322cd2a80e1da73a254
parent 6004a047053e97b9f613d8329f690d1fd6d920fb
Author: ThomasV <thomasv@electrum.org>
Date:   Fri, 12 Mar 2021 11:40:53 +0100

fix wallet get_full_history: add onchain tx for channels not opened by us

Diffstat:
Melectrum/lnworker.py | 6+++++-
Melectrum/wallet.py | 13+++++++++----
2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/electrum/lnworker.py b/electrum/lnworker.py @@ -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: diff --git a/electrum/wallet.py b/electrum/wallet.py @@ -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():