Browse Source

submarine swaps: disable merging of transaction in history

This is too complicated and ugly because it relies on side
effects. What we should do instead is collapse transactions
in children nodes of QTreeView (see #6237)
master
ThomasV 6 years ago
parent
commit
cb4c8abe1c
  1. 27
      electrum/lnworker.py
  2. 26
      electrum/wallet.py

27
electrum/lnworker.py

@ -634,10 +634,10 @@ class LNWallet(LNWorker):
swap = self.swap_manager.get_swap(payment_hash) swap = self.swap_manager.get_swap(payment_hash)
if swap: if swap:
if swap.is_reverse: if swap.is_reverse:
item['txid'] = swap.spending_txid #item['txid'] = swap.spending_txid
item['label'] = 'Reverse swap' + ' ' + self.config.format_amount_and_units(swap.lightning_amount) item['label'] = 'Reverse swap' + ' ' + self.config.format_amount_and_units(swap.lightning_amount)
else: else:
item['txid'] = swap.funding_txid #item['txid'] = swap.funding_txid
item['label'] = 'Normal swap' + ' ' + self.config.format_amount_and_units(swap.onchain_amount) item['label'] = 'Normal swap' + ' ' + self.config.format_amount_and_units(swap.onchain_amount)
# done # done
out[payment_hash] = item out[payment_hash] = item
@ -677,29 +677,6 @@ class LNWallet(LNWorker):
'fee_msat': None, 'fee_msat': None,
} }
out[closing_txid] = item out[closing_txid] = item
# add submarine swaps
settled_payments = self.get_settled_payments()
current_height = self.network.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:
continue
if payment_hash_hex in settled_payments:
plist = settled_payments[payment_hash_hex]
info = self.get_payment_info(bytes.fromhex(payment_hash_hex))
amount_msat, fee_msat, timestamp = self.get_payment_value(info, plist)
else:
amount_msat = 0
label = 'Reverse swap' if swap.is_reverse else 'Normal swap'
delta = current_height - swap.locktime
if delta < 0:
label += f' (refundable in {-delta} blocks)'
out[txid] = {
'txid': txid,
'amount_msat': amount_msat,
'type': 'swap',
'label': label
}
return out return out
def get_history(self): def get_history(self):

26
electrum/wallet.py

@ -820,31 +820,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 LN txns
if txid in lnworker_history: if self.lnworker and include_lightning:
item = lnworker_history[txid] lightning_history = self.lnworker.get_history()
tx_item['label'] = item['label'] else:
tx_item['type'] = item['type'] lightning_history = []
ln_value = Decimal(item['amount_msat']) / 1000 for i, tx_item in enumerate(lightning_history):
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():
txid = tx_item.get('txid') txid = tx_item.get('txid')
ln_value = Decimal(tx_item['amount_msat']) / 1000 ln_value = Decimal(tx_item['amount_msat']) / 1000
# merge items that have a txid with onchain tx
if txid and txid in transactions_tmp: if txid and txid in transactions_tmp:
item = transactions_tmp[txid] item = transactions_tmp[txid]
item['label'] = tx_item['label'] item['label'] = tx_item['label']
item['type'] = tx_item['type'] # fixme: do we need this? item['type'] = tx_item['type']
if 'ln_value' not in item: item['channel_id'] = tx_item['channel_id']
item['ln_value'] = 0 item['ln_value'] = Satoshis(ln_value)
item['ln_value'] = Satoshis(ln_value) # fixme: we need to add value
item['amount_msat'] = tx_item['amount_msat']
else: else:
tx_item['lightning'] = True tx_item['lightning'] = True
tx_item['ln_value'] = Satoshis(ln_value) tx_item['ln_value'] = Satoshis(ln_value)

Loading…
Cancel
Save