Browse Source

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

Better to always call it, to make sure inputs have identical sequence numbers.
patch-4
SomberNight 4 years ago
parent
commit
914eb9989d
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 3
      electrum/gui/kivy/uix/dialogs/tx_dialog.py
  2. 3
      electrum/gui/qt/confirm_tx_dialog.py
  3. 4
      electrum/gui/qt/main_window.py
  4. 3
      electrum/transaction.py
  5. 13
      electrum/wallet.py

3
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()

3
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:

4
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):

3
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):

13
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

Loading…
Cancel
Save