electrum

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

commit 55b5335ebb2cdfac488203b5048e17a615d08a30
parent 82c8c4280f598c3755448eb988ad89821cd61a53
Author: SomberNight <somber.night@protonmail.com>
Date:   Fri, 16 Oct 2020 21:08:41 +0200

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.

Diffstat:
Melectrum/address_synchronizer.py | 13+++++++++++++
Melectrum/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 @@ -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 @@ -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()))