tbump_dee and dscancel: call tx.estimated_size() after add_input_info(). This is a workaround, see the FIXME. PartialTxInput.is_segwit() should return the correct value, or raise if information is missing. - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit f130cb53ce42339901e1189e61423163e1a0a372 DIR parent 091d7e104a8ff824d5e623413e1d8b1e52f9c6b4 HTML Author: ThomasV <thomasv@electrum.org> Date: Sun, 17 Jan 2021 17:16:51 +0100 bump_dee and dscancel: call tx.estimated_size() after add_input_info(). This is a workaround, see the FIXME. PartialTxInput.is_segwit() should return the correct value, or raise if information is missing. Diffstat: M electrum/transaction.py | 4 ++++ M electrum/wallet.py | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) --- DIR diff --git a/electrum/transaction.py b/electrum/transaction.py t@@ -1171,6 +1171,10 @@ class PartialTxInput(TxInput, PSBTSection): @classmethod def from_txin(cls, txin: TxInput, *, strip_witness: bool = True) -> 'PartialTxInput': + # FIXME: if strip_witness is True, res.is_segwit() will return False, + # and res.estimated_size() will return an incorrect value. These methods + # will return the correct values after we call add_input_info(). (see dscancel and bump_fee) + # This is very fragile: the value returned by estimate_size() depends on the calling order. res = PartialTxInput(prevout=txin.prevout, script_sig=None if strip_witness else txin.script_sig, nsequence=txin.nsequence, DIR diff --git a/electrum/wallet.py b/electrum/wallet.py t@@ -1394,12 +1394,12 @@ class Abstract_Wallet(AddressSynchronizer, ABC): if tx.is_final(): raise CannotBumpFee(_('Transaction is final')) new_fee_rate = quantize_feerate(new_fee_rate) # strip excess precision - old_tx_size = tx.estimated_size() try: # note: this might download input utxos over network tx.add_info_from_wallet(self, ignore_network_issues=False) except NetworkException as e: raise CannotBumpFee(repr(e)) + old_tx_size = tx.estimated_size() old_fee = tx.get_fee() assert old_fee is not None old_fee_rate = old_fee / old_tx_size # sat/vbyte t@@ -1573,12 +1573,12 @@ class Abstract_Wallet(AddressSynchronizer, ABC): if tx.is_final(): raise CannotDoubleSpendTx(_('Transaction is final')) new_fee_rate = quantize_feerate(new_fee_rate) # strip excess precision - old_tx_size = tx.estimated_size() try: # note: this might download input utxos over network tx.add_info_from_wallet(self, ignore_network_issues=False) except NetworkException as e: raise CannotDoubleSpendTx(repr(e)) + old_tx_size = tx.estimated_size() old_fee = tx.get_fee() assert old_fee is not None old_fee_rate = old_fee / old_tx_size # sat/vbyte