electrum

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

commit 914eb9989d3a595ba4ee3889aa9f171551e50091
parent ca86e3572442d294674cb2c252a1540a15344ebe
Author: SomberNight <somber.night@protonmail.com>
Date:   Thu, 11 Feb 2021 21:52:34 +0100

wallet: minor clean-up of tx.set_rbf() calls

Better to always call it, to make sure inputs have identical sequence numbers.

Diffstat:
Melectrum/gui/kivy/uix/dialogs/tx_dialog.py | 3+--
Melectrum/gui/qt/confirm_tx_dialog.py | 3+--
Melectrum/gui/qt/main_window.py | 4+---
Melectrum/transaction.py | 3++-
Melectrum/wallet.py | 13+++++++------
5 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/electrum/gui/kivy/uix/dialogs/tx_dialog.py b/electrum/gui/kivy/uix/dialogs/tx_dialog.py @@ -282,8 +282,7 @@ class TxDialog(Factory.Popup): except CannotBumpFee as e: self.app.show_error(str(e)) return - if is_final: - new_tx.set_rbf(False) + new_tx.set_rbf(not is_final) self.tx = new_tx self.update() self.do_sign() diff --git a/electrum/gui/qt/confirm_tx_dialog.py b/electrum/gui/qt/confirm_tx_dialog.py @@ -111,8 +111,7 @@ class TxEditor: self.main_window.show_error(str(e)) raise use_rbf = bool(self.config.get('use_rbf', True)) - if use_rbf: - self.tx.set_rbf(True) + self.tx.set_rbf(use_rbf) def have_enough_funds_assuming_zero_fees(self) -> bool: try: diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py @@ -3242,7 +3242,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): except CannotCPFP as e: self.show_error(str(e)) return - new_tx.set_rbf(True) self.show_transaction(new_tx) def _add_info_to_tx_from_wallet_and_network(self, tx: PartialTransaction) -> bool: @@ -3329,8 +3328,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): except Exception as e: self.show_error(str(e)) return - if is_final: - new_tx.set_rbf(False) + new_tx.set_rbf(not is_final) self.show_transaction(new_tx, tx_desc=tx_label) def bump_fee_dialog(self, tx: Transaction): diff --git a/electrum/transaction.py b/electrum/transaction.py @@ -864,7 +864,8 @@ class Transaction: def add_info_from_wallet(self, wallet: 'Abstract_Wallet', **kwargs) -> None: return # no-op - def is_final(self): + def is_final(self) -> bool: + """Whether RBF is disabled.""" return not any([txin.nsequence < 0xffffffff - 1 for txin in self.inputs()]) def estimated_size(self): diff --git a/electrum/wallet.py b/electrum/wallet.py @@ -195,9 +195,8 @@ async def sweep( locktime = get_locktime_for_new_transaction(network) tx = PartialTransaction.from_io(inputs, outputs, locktime=locktime, version=tx_version) - rbf = config.get('use_rbf', True) - if rbf: - tx.set_rbf(True) + rbf = bool(config.get('use_rbf', True)) + tx.set_rbf(rbf) tx.sign(keypairs) return tx @@ -1303,6 +1302,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC): # Timelock tx to current height. tx.locktime = get_locktime_for_new_transaction(self.network) + tx.set_rbf(False) # caller can set RBF manually later tx.add_info_from_wallet(self) run_hook('make_unsigned_transaction', self, tx) return tx @@ -1606,6 +1606,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC): outputs = [PartialTxOutput.from_address_and_value(out_address, output_value)] locktime = get_locktime_for_new_transaction(self.network) tx_new = PartialTransaction.from_io(inputs, outputs, locktime=locktime) + tx_new.set_rbf(True) tx_new.add_info_from_wallet(self) return tx_new @@ -1656,6 +1657,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC): raise CannotDoubleSpendTx(_("The output value remaining after fee is too low.")) outputs = [PartialTxOutput.from_address_and_value(out_address, value - new_fee)] tx_new = PartialTransaction.from_io(inputs, outputs, locktime=locktime) + tx_new.set_rbf(True) tx_new.add_info_from_wallet(self) return tx_new @@ -2301,9 +2303,8 @@ class Abstract_Wallet(AddressSynchronizer, ABC): if locktime is not None: tx.locktime = locktime if rbf is None: - rbf = self.config.get('use_rbf', True) - if rbf: - tx.set_rbf(True) + rbf = bool(self.config.get('use_rbf', True)) + tx.set_rbf(rbf) if not unsigned: self.sign_transaction(tx, password) return tx