mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 17:31:36 +00:00
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
This commit is contained in:
parent
844bbd103a
commit
8f96a92e75
2 changed files with 20 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue