1
0

show swaps as single line in history

main_window.run_coroutine_from_thread
This commit is contained in:
ThomasV
2020-05-26 10:02:27 +02:00
parent 46770bfd71
commit f8dd62aec0
6 changed files with 65 additions and 15 deletions

View File

@@ -626,9 +626,37 @@ class LNWallet(LNWorker):
'payment_hash': key,
'preimage': preimage,
}
# add txid to merge item with onchain item
swap_info = self.swap_manager.get_swap(preimage)
if swap_info:
is_reverse = swap_info.get('invoice')
if is_reverse:
item['txid'] = swap_info.get('claim_txid')
lightning_amount = swap_info.get('lightning_amount')
item['label'] = 'Reverse swap' + ' ' + self.config.format_amount_and_units(lightning_amount)
else:
item['txid'] = swap_info.get('funding_txid')
onchain_amount = swap_info["expectedAmount"]
item['label'] = 'Normal swap' + ' ' + self.config.format_amount_and_units(onchain_amount)
# done
out[payment_hash] = item
return out
def get_swap_history(self):
out = {}
for k, swap_info in self.swap_manager.swaps.items():
is_reverse = swap_info.get('invoice')
if is_reverse:
txid = swap_info.get('claim_txid')
else:
txid = swap_info.get('funding_txid')
if txid is None:
continue
out[txid] = {
'lightning_amount': swap_info.get('lightning_amount', 0) * (-1 if is_reverse else 1)
}
return out
def get_onchain_history(self):
out = {}
# add funding events