commit 5bf3115a4a8f35c12d87602b3dea27ce62603a8f
parent b9bb78a1db47343355b0fad7d7a5db711e504df2
Author: SomberNight <somber.night@protonmail.com>
Date: Fri, 1 May 2020 07:51:29 +0200
qt send tab: (fix) allow user to set lower fees if "not enough funds"
Previously if the user tried to pay an invoice, we tried to construct
a tx with the desired feerate. If this raise NotEnoughFunds, we would just
show the error and not let the user change the feerate.
related: https://github.com/spesmilo/electrum/issues/6136#issuecomment-622254754 (method 2)
Diffstat:
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/electrum/gui/qt/confirm_tx_dialog.py b/electrum/gui/qt/confirm_tx_dialog.py
@@ -104,7 +104,13 @@ class TxEditor:
if use_rbf:
self.tx.set_rbf(True)
-
+ def have_enough_funds_assuming_zero_fees(self) -> bool:
+ try:
+ tx = self.make_tx(0)
+ except NotEnoughFunds:
+ return False
+ else:
+ return True
diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py
@@ -1594,8 +1594,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
output_value = '!' if '!' in output_values else sum(output_values)
d = ConfirmTxDialog(window=self, make_tx=make_tx, output_value=output_value, is_sweep=is_sweep)
if d.not_enough_funds:
- self.show_message(_('Not Enough Funds'))
- return
+ # Check if we had enough funds excluding fees,
+ # if so, still provide opportunity to set lower fees.
+ if not d.have_enough_funds_assuming_zero_fees():
+ self.show_message(_('Not Enough Funds'))
+ return
cancelled, is_send, password, tx = d.run()
if cancelled:
return