URI: 
       tqt PreviewTxDialog: if not enough funds due to fee, fallback to zero fee - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 8f96a92e7544f42223a10b78d7cedb232fcf7231
   DIR parent 844bbd103a48f8def6365e7d331b588c12d7a04f
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Thu,  2 Jul 2020 13:29:51 +0200
       
       qt PreviewTxDialog: if not enough funds due to fee, fallback to zero fee
       
       fixes #6306
       
       scenario: confirm tx dialog open, not enough funds (but only due to fees),
       user clicks advanced, dialog half-empty.
       
       note: the preview dialog is only half-empty if it never managed to create a tx.
       if it did but it cannot now due to the current fee settings, then it will just
       show that fee is too high (red text, buttons disabled) and show the last tx with the prev fee
       
       Diffstat:
         M electrum/gui/qt/confirm_tx_dialog.… |      10 ++++++++--
         M electrum/gui/qt/transaction_dialog… |      15 ++++++++++++---
       
       2 files changed, 20 insertions(+), 5 deletions(-)
       ---
   DIR diff --git a/electrum/gui/qt/confirm_tx_dialog.py b/electrum/gui/qt/confirm_tx_dialog.py
       t@@ -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)
       t@@ -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
   DIR diff --git a/electrum/gui/qt/transaction_dialog.py b/electrum/gui/qt/transaction_dialog.py
       t@@ -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()
       t@@ -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
        
       t@@ -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):
       t@@ -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()