From 55b5335ebb2cdfac488203b5048e17a615d08a30 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 16 Oct 2020 21:08:41 +0200 Subject: [PATCH] qt tx dialog: always show input amounts if we know them Previously we would only show input amounts for partial txs. Now also show them for complete txs as well, if we know them: we check in the wallet db for the prevtx and read the value for the output. This is safe as the input commits to the prevout via txid (which commits to the output value). Also show "from addresses" in more cases in a similar fashion. --- electrum/address_synchronizer.py | 13 +++++++++++++ electrum/gui/qt/transaction_dialog.py | 5 +++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/electrum/address_synchronizer.py b/electrum/address_synchronizer.py index e98fc2a57..1ca3cf1b3 100644 --- a/electrum/address_synchronizer.py +++ b/electrum/address_synchronizer.py @@ -139,6 +139,19 @@ class AddressSynchronizer(Logger): for n, v, is_cb in l: if n == prevout_n: return addr + tx = self.db.get_transaction(prevout_hash) + if tx: + return tx.outputs()[prevout_n].address + return None + + def get_txin_value(self, txin: TxInput) -> Optional[int]: + if txin.value_sats() is not None: + return txin.value_sats() + prevout_hash = txin.prevout.txid.hex() + prevout_n = txin.prevout.out_idx + tx = self.db.get_transaction(prevout_hash) + if tx: + return tx.outputs()[prevout_n].value return None def get_txout_address(self, txo: TxOutput) -> Optional[str]: diff --git a/electrum/gui/qt/transaction_dialog.py b/electrum/gui/qt/transaction_dialog.py index 0b920213b..3d7393bd6 100644 --- a/electrum/gui/qt/transaction_dialog.py +++ b/electrum/gui/qt/transaction_dialog.py @@ -551,8 +551,9 @@ class BaseTxDialog(QDialog, MessageBoxMixin): if addr is None: addr = '' cursor.insertText(addr, text_format(addr)) - if isinstance(txin, PartialTxInput) and txin.value_sats() is not None: - cursor.insertText(format_amount(txin.value_sats()), ext) + txin_value = self.wallet.get_txin_value(txin) + if txin_value is not None: + cursor.insertText(format_amount(txin_value), ext) cursor.insertBlock() self.outputs_header.setText(_("Outputs") + ' (%d)'%len(self.tx.outputs()))