From c438f1dfe780f06112193ba4c8e3267c606e706a Mon Sep 17 00:00:00 2001 From: f321x Date: Fri, 5 Sep 2025 17:43:03 +0200 Subject: [PATCH] wallet history: also add fiat value to child tx Makes `get_full_history` also add the fiat values to the children of a tx, not only to the group itself. --- electrum/wallet.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/electrum/wallet.py b/electrum/wallet.py index e28778abd..814a8beb5 100644 --- a/electrum/wallet.py +++ b/electrum/wallet.py @@ -1514,17 +1514,20 @@ class Abstract_Wallet(ABC, Logger, EventListener): item['value'] = item.get('bc_value', Satoshis(0)) + item.get('ln_value', Satoshis(0)) for child in item.get('children', []): child['value'] = child.get('bc_value', Satoshis(0)) + child.get('ln_value', Satoshis(0)) - if include_fiat: - value = item['value'].value - txid = item.get('txid') - if not item.get('lightning') and txid: - fiat_fields = self.get_tx_item_fiat(tx_hash=txid, amount_sat=value, fx=fx, tx_fee=item['fee_sat']) - item.update(fiat_fields) + if not include_fiat: + continue + # add fiat values to both the root item and its children + for add_fiat_item in [item] + children: + value = add_fiat_item['value'].value + txid = add_fiat_item.get('txid') + if not add_fiat_item.get('lightning') and txid: + fiat_fields = self.get_tx_item_fiat(tx_hash=txid, amount_sat=value, fx=fx, tx_fee=add_fiat_item['fee_sat']) + add_fiat_item.update(fiat_fields) else: - timestamp = item['timestamp'] or now + timestamp = add_fiat_item['timestamp'] or now fiat_value = value / Decimal(bitcoin.COIN) * fx.timestamp_rate(timestamp) - item['fiat_value'] = Fiat(fiat_value, fx.ccy) - item['fiat_default'] = True + add_fiat_item['fiat_value'] = Fiat(fiat_value, fx.ccy) + add_fiat_item['fiat_default'] = True return transactions @profiler