diff --git a/electrum/gui/qt/confirm_tx_dialog.py b/electrum/gui/qt/confirm_tx_dialog.py index 6e1091137..ea937a51b 100644 --- a/electrum/gui/qt/confirm_tx_dialog.py +++ b/electrum/gui/qt/confirm_tx_dialog.py @@ -80,7 +80,7 @@ class TxEditor: def get_fee_estimator(self): return None - def update_tx(self): + def update_tx(self, *, fallback_to_zero_fee: bool = False): fee_estimator = self.get_fee_estimator() try: self.tx = self.make_tx(fee_estimator) @@ -89,7 +89,13 @@ class TxEditor: except NotEnoughFunds: self.not_enough_funds = True self.tx = None - return + if fallback_to_zero_fee: + try: + self.tx = self.make_tx(0) + except BaseException: + return + else: + return except NoDynamicFeeEstimates: self.no_dynfee_estimates = True self.tx = None diff --git a/electrum/gui/qt/transaction_dialog.py b/electrum/gui/qt/transaction_dialog.py index 09301c00a..c84ad4836 100644 --- a/electrum/gui/qt/transaction_dialog.py +++ b/electrum/gui/qt/transaction_dialog.py @@ -393,7 +393,7 @@ class BaseTxDialog(QDialog, MessageBoxMixin): def update(self): if not self.finalized: self.update_fee_fields() - self.finalize_button.setEnabled(self.tx is not None) + self.finalize_button.setEnabled(self.can_finalize()) if self.tx is None: return self.update_io() @@ -659,6 +659,9 @@ class BaseTxDialog(QDialog, MessageBoxMixin): def set_title(self): self.setWindowTitle(_("Create transaction") if not self.finalized else _("Transaction")) + def can_finalize(self) -> bool: + return False + def on_finalize(self): pass # overridden in subclass @@ -688,7 +691,8 @@ class PreviewTxDialog(BaseTxDialog, TxEditor): TxEditor.__init__(self, window=window, make_tx=make_tx, is_sweep=bool(external_keypairs)) BaseTxDialog.__init__(self, parent=window, desc='', prompt_if_unsaved=False, finalized=False, external_keypairs=external_keypairs) - BlockingWaitingDialog(window, _("Preparing transaction..."), self.update_tx) + BlockingWaitingDialog(window, _("Preparing transaction..."), + lambda: self.update_tx(fallback_to_zero_fee=True)) self.update() def create_fee_controls(self): @@ -861,9 +865,14 @@ class PreviewTxDialog(BaseTxDialog, TxEditor): self.feerounding_icon.setToolTip(self.feerounding_text) self.feerounding_icon.setVisible(abs(feerounding) >= 1) + def can_finalize(self): + return (self.tx is not None + and not self.not_enough_funds) + def on_finalize(self): - if not self.tx: + if not self.can_finalize(): return + assert self.tx self.finalized = True self.tx.set_rbf(self.rbf_cb.isChecked()) self.tx.locktime = self.locktime_e.get_locktime()