From b4d2c902c4a3bbd812442049d71897f67a171297 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 3 Feb 2023 16:09:06 +0000 Subject: [PATCH] qt tx dialog: fix for pre-segwit legacy wallets ``` Traceback (most recent call last): File "/home/user/wspace/electrum/electrum/gui/qt/invoice_list.py", line 169, in menu.addAction(_("Pay") + "...", lambda: self.send_tab.do_pay_invoice(invoice)) File "/home/user/wspace/electrum/electrum/gui/qt/send_tab.py", line 585, in do_pay_invoice self.pay_onchain_dialog(self.window.get_coins(), invoice.outputs) File "/home/user/wspace/electrum/electrum/gui/qt/send_tab.py", line 271, in pay_onchain_dialog preview_dlg = PreviewTxDialog( File "/home/user/wspace/electrum/electrum/gui/qt/transaction_dialog.py", line 962, in __init__ self.update() File "/home/user/wspace/electrum/electrum/gui/qt/transaction_dialog.py", line 658, in update self.io_widget.update(self.tx) File "/home/user/wspace/electrum/electrum/gui/qt/transaction_dialog.py", line 212, in update tx_height, tx_pos = self.wallet.adb.get_txpos(self.tx.txid()) File "/home/user/wspace/electrum/electrum/address_synchronizer.py", line 483, in get_txpos verified_tx_mined_info = self.db.get_verified_tx(tx_hash) File "/home/user/wspace/electrum/electrum/json_db.py", line 44, in wrapper return func(self, *args, **kwargs) File "/home/user/wspace/electrum/electrum/wallet_db.py", line 1256, in get_verified_tx assert isinstance(txid, str) AssertionError ``` --- electrum/gui/qt/transaction_dialog.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/electrum/gui/qt/transaction_dialog.py b/electrum/gui/qt/transaction_dialog.py index bb1374e89..4abde8c4f 100644 --- a/electrum/gui/qt/transaction_dialog.py +++ b/electrum/gui/qt/transaction_dialog.py @@ -226,14 +226,18 @@ class TxInOutWidget(QWidget): o_text.clear() o_text.setFont(QFont(MONOSPACE_FONT)) o_text.setReadOnly(True) - tx_height, tx_pos = self.wallet.adb.get_txpos(self.tx.txid()) - tx_hash = bytes.fromhex(self.tx.txid()) + tx_height, tx_pos = None, None + tx_hash = self.tx.txid() + if tx_hash: + tx_height, tx_pos = self.wallet.adb.get_txpos(tx_hash) cursor = o_text.textCursor() for txout_idx, o in enumerate(self.tx.outputs()): - if tx_pos is not None and tx_pos >= 0: + if tx_height is not None and tx_pos is not None and tx_pos >= 0: short_id = ShortID.from_components(tx_height, tx_pos, txout_idx) + elif tx_hash: + short_id = TxOutpoint(bytes.fromhex(tx_hash), txout_idx).short_name() else: - short_id = TxOutpoint(tx_hash, txout_idx).short_name() + short_id = f"unknown:{txout_idx}" addr = o.get_ui_address_str() insert_tx_io( cursor=cursor, is_coinbase=False, txio_idx=txout_idx,