mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 17:31:36 +00:00
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.
This commit is contained in:
parent
82c8c4280f
commit
55b5335ebb
2 changed files with 16 additions and 2 deletions
|
@ -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]:
|
||||
|
|
|
@ -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()))
|
||||
|
|
Loading…
Add table
Reference in a new issue