diff --git a/electrum/commands.py b/electrum/commands.py index ecce99efb..d16d04cad 100644 --- a/electrum/commands.py +++ b/electrum/commands.py @@ -817,7 +817,6 @@ class Commands: await tx.add_info_from_network(self.network) new_tx = wallet.bump_fee( tx=tx, - txid=tx.txid(), coins=coins, strategy=BumpFeeStrategy.DECREASE_PAYMENT if decrease_payment else BumpFeeStrategy.PRESERVE_PAYMENT, new_fee_rate=new_fee_rate) diff --git a/electrum/gui/qml/qetxfinalizer.py b/electrum/gui/qml/qetxfinalizer.py index 46686372b..729f80005 100644 --- a/electrum/gui/qml/qetxfinalizer.py +++ b/electrum/gui/qml/qetxfinalizer.py @@ -543,7 +543,7 @@ class QETxRbfFeeBumper(TxFeeSlider, TxMonMixin): self._orig_tx = self._wallet.wallet.db.get_transaction(self._txid) assert self._orig_tx - strategies, def_strat_idx = self._wallet.wallet.get_bumpfee_strategies_for_tx(tx=self._orig_tx, txid=self._txid) + strategies, def_strat_idx = self._wallet.wallet.get_bumpfee_strategies_for_tx(tx=self._orig_tx) self._bump_methods_available = [{'value': strat.name, 'text': strat.text()} for strat in strategies] self.bumpMethodsAvailableChanged.emit() self.bumpMethod = strategies[def_strat_idx].name @@ -581,7 +581,6 @@ class QETxRbfFeeBumper(TxFeeSlider, TxMonMixin): try: self._tx = self._wallet.wallet.bump_fee( tx=self._orig_tx, - txid=self._txid, new_fee_rate=new_fee_rate, strategy=BumpFeeStrategy[self._bump_method], ) diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py index ecb1ddbd7..3e132c9e2 100644 --- a/electrum/gui/qt/main_window.py +++ b/electrum/gui/qt/main_window.py @@ -2633,21 +2633,19 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener): self.show_transaction(new_tx) def bump_fee_dialog(self, tx: Transaction): - txid = tx.txid() if not isinstance(tx, PartialTransaction): tx = PartialTransaction.from_tx(tx) if not tx.add_info_from_wallet_and_network(wallet=self.wallet, show_error=self.show_error): return - d = BumpFeeDialog(main_window=self, tx=tx, txid=txid) + d = BumpFeeDialog(main_window=self, tx=tx) d.run() def dscancel_dialog(self, tx: Transaction): - txid = tx.txid() if not isinstance(tx, PartialTransaction): tx = PartialTransaction.from_tx(tx) if not tx.add_info_from_wallet_and_network(wallet=self.wallet, show_error=self.show_error): return - d = DSCancelDialog(main_window=self, tx=tx, txid=txid) + d = DSCancelDialog(main_window=self, tx=tx) d.run() def save_transaction_into_wallet(self, tx: Transaction): diff --git a/electrum/gui/qt/rbf_dialog.py b/electrum/gui/qt/rbf_dialog.py index db04f99f4..abb6fd385 100644 --- a/electrum/gui/qt/rbf_dialog.py +++ b/electrum/gui/qt/rbf_dialog.py @@ -30,13 +30,10 @@ class _BaseRBFDialog(TxEditor): *, main_window: 'ElectrumWindow', tx: PartialTransaction, - txid: str, title: str): self.wallet = main_window.wallet self.old_tx = tx - assert txid - self.old_txid = txid self.message = '' self.old_fee = self.old_tx.get_fee() @@ -58,7 +55,7 @@ class _BaseRBFDialog(TxEditor): def create_grid(self): self.method_label = QLabel(_('Method') + ':') self.method_combo = QComboBox() - self._strategies, def_strat_idx = self.wallet.get_bumpfee_strategies_for_tx(tx=self.old_tx, txid=self.old_txid) + self._strategies, def_strat_idx = self.wallet.get_bumpfee_strategies_for_tx(tx=self.old_tx) self.method_combo.addItems([strat.text() for strat in self._strategies]) self.method_combo.setCurrentIndex(def_strat_idx) self.method_combo.currentIndexChanged.connect(self.trigger_update) @@ -140,18 +137,16 @@ class BumpFeeDialog(_BaseRBFDialog): *, main_window: 'ElectrumWindow', tx: PartialTransaction, - txid: str): + ): _BaseRBFDialog.__init__( self, main_window=main_window, tx=tx, - txid=txid, title=_('Bump Fee')) def rbf_func(self, fee_rate, *, confirmed_only=False): return self.wallet.bump_fee( tx=self.old_tx, - txid=self.old_txid, new_fee_rate=fee_rate, coins=self.main_window.get_coins(nonlocal_only=True, confirmed_only=confirmed_only), strategy=self._strategies[self.method_combo.currentIndex()], @@ -169,12 +164,11 @@ class DSCancelDialog(_BaseRBFDialog): *, main_window: 'ElectrumWindow', tx: PartialTransaction, - txid: str): + ): _BaseRBFDialog.__init__( self, main_window=main_window, tx=tx, - txid=txid, title=_('Cancel transaction')) self.method_label.setVisible(False) self.method_combo.setVisible(False) diff --git a/electrum/wallet.py b/electrum/wallet.py index bb7ddfccf..d2c9caf62 100644 --- a/electrum/wallet.py +++ b/electrum/wallet.py @@ -1243,7 +1243,9 @@ class Abstract_Wallet(ABC, Logger, EventListener): def export_invoices(self, path): write_json_file(path, list(self._invoices.values())) - def get_relevant_invoices_for_tx(self, tx_hash) -> Sequence[Invoice]: + def get_relevant_invoices_for_tx(self, tx_hash: Optional[str]) -> Sequence[Invoice]: + if not tx_hash: + return [] invoice_keys = self._invoices_from_txid_map.get(tx_hash, set()) invoices = [self.get_invoice(key) for key in invoice_keys] invoices = [inv for inv in invoices if inv] # filter out None @@ -2042,15 +2044,11 @@ class Abstract_Wallet(ABC, Logger, EventListener): self, *, tx: Transaction, - txid: str = None, ) -> Tuple[Sequence[BumpFeeStrategy], int]: """Returns tuple(list of available strategies, idx of recommended option among those).""" - txid = txid or tx.txid() - assert txid - assert tx.txid() in (None, txid) all_strats = BumpFeeStrategy.all() # are we paying max? - invoices = self.get_relevant_invoices_for_tx(txid) + invoices = self.get_relevant_invoices_for_tx(tx.txid()) if len(invoices) == 1 and len(invoices[0].outputs) == 1: if invoices[0].outputs[0].value == '!': return all_strats, all_strats.index(BumpFeeStrategy.DECREASE_PAYMENT) @@ -2064,7 +2062,6 @@ class Abstract_Wallet(ABC, Logger, EventListener): self, *, tx: Transaction, - txid: str = None, new_fee_rate: Union[int, float, Decimal], coins: Sequence[PartialTxInput] = None, strategy: BumpFeeStrategy = BumpFeeStrategy.PRESERVE_PAYMENT, @@ -2076,9 +2073,6 @@ class Abstract_Wallet(ABC, Logger, EventListener): note: it is the caller's responsibility to have already called tx.add_info_from_network(). Without that, all txins must be ismine. """ - txid = txid or tx.txid() - assert txid - assert tx.txid() in (None, txid) if not isinstance(tx, PartialTransaction): tx = PartialTransaction.from_tx(tx) assert isinstance(tx, PartialTransaction) @@ -2102,7 +2096,6 @@ class Abstract_Wallet(ABC, Logger, EventListener): try: tx_new = self._bump_fee_through_coinchooser( tx=tx, - txid=txid, new_fee_rate=new_fee_rate, coins=coins, ) @@ -2131,7 +2124,6 @@ class Abstract_Wallet(ABC, Logger, EventListener): self, *, tx: PartialTransaction, - txid: str, new_fee_rate: Union[int, Decimal], coins: Sequence[PartialTxInput] = None, ) -> PartialTransaction: @@ -2141,7 +2133,6 @@ class Abstract_Wallet(ABC, Logger, EventListener): - keeps all not is_mine outputs, - allows adding new inputs """ - assert txid tx = copy.deepcopy(tx) tx.add_info_from_wallet(self) assert tx.get_fee() is not None @@ -2170,7 +2161,8 @@ class Abstract_Wallet(ABC, Logger, EventListener): if coins is None: coins = self.get_spendable_coins(None) # make sure we don't try to spend output from the tx-to-be-replaced: - coins = [c for c in coins if c.prevout.txid.hex() != txid] + coins = [c for c in coins + if c.prevout.txid.hex() not in self.adb.get_conflicting_transactions(tx, include_self=True)] for item in coins: self.add_input_info(item) def fee_estimator(size):