Merge pull request #9713 from accumulator/improve_not_enough_funds_mentioning_frozen
wallet,gui: improve not_enough_funds_mentioning_frozen
This commit is contained in:
@@ -402,9 +402,10 @@ class QETxFinalizer(TxFeeSlider):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
# make unsigned transaction
|
# make unsigned transaction
|
||||||
tx = self.make_tx(amount='!' if self._amount.isMax else self._amount.satsInt)
|
amount = '!' if self._amount.isMax else self._amount.satsInt
|
||||||
|
tx = self.make_tx(amount=amount)
|
||||||
except NotEnoughFunds:
|
except NotEnoughFunds:
|
||||||
self.warning = _("Not enough funds")
|
self.warning = self._wallet.wallet.get_text_not_enough_funds_mentioning_frozen(for_amount=amount)
|
||||||
self._valid = False
|
self._valid = False
|
||||||
self.validChanged.emit()
|
self.validChanged.emit()
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -851,6 +851,6 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
|||||||
amount = tx.output_value()
|
amount = tx.output_value()
|
||||||
except NotEnoughFunds as e:
|
except NotEnoughFunds as e:
|
||||||
self._logger.debug(str(e))
|
self._logger.debug(str(e))
|
||||||
message = self.wallet.get_text_not_enough_funds_mentioning_frozen()
|
message = self.wallet.get_text_not_enough_funds_mentioning_frozen(for_amount='!')
|
||||||
|
|
||||||
return amount, message
|
return amount, message
|
||||||
|
|||||||
@@ -490,8 +490,10 @@ class TxEditor(WindowModalDialog):
|
|||||||
elif self.can_pay_assuming_zero_fees(confirmed_only=confirmed_only):
|
elif self.can_pay_assuming_zero_fees(confirmed_only=confirmed_only):
|
||||||
self.error += ' ' + _('You need to set a lower fee.')
|
self.error += ' ' + _('You need to set a lower fee.')
|
||||||
elif frozen_bal := self.wallet.get_frozen_balance_str():
|
elif frozen_bal := self.wallet.get_frozen_balance_str():
|
||||||
# FIXME only show if unfreezing would fix "not enough funds"
|
self.error = self.wallet.get_text_not_enough_funds_mentioning_frozen(
|
||||||
self.error += ' ' + _("Some coins are frozen: {} (can be unfrozen in the Addresses or in the Coins tab)").format(frozen_bal)
|
for_amount=self.output_value,
|
||||||
|
hint=_('Can be unfrozen in the Addresses or in the Coins tab')
|
||||||
|
)
|
||||||
if not self.tx:
|
if not self.tx:
|
||||||
if self.not_enough_funds:
|
if self.not_enough_funds:
|
||||||
self.io_widget.update(None)
|
self.io_widget.update(None)
|
||||||
|
|||||||
@@ -1437,7 +1437,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
|
|||||||
# note: use confirmed_only=False here, regardless of config setting,
|
# note: use confirmed_only=False here, regardless of config setting,
|
||||||
# as the user needs to get to ConfirmTxDialog to change the config setting
|
# as the user needs to get to ConfirmTxDialog to change the config setting
|
||||||
if not d.can_pay_assuming_zero_fees(confirmed_only=False):
|
if not d.can_pay_assuming_zero_fees(confirmed_only=False):
|
||||||
text = self.wallet.get_text_not_enough_funds_mentioning_frozen()
|
text = self.wallet.get_text_not_enough_funds_mentioning_frozen(for_amount=output_value)
|
||||||
self.show_message(text)
|
self.show_message(text)
|
||||||
return
|
return
|
||||||
return d.run(), d.is_preview
|
return d.run(), d.is_preview
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ class SendTab(QWidget, MessageBoxMixin, Logger):
|
|||||||
tx = make_tx(FixedFeePolicy(0))
|
tx = make_tx(FixedFeePolicy(0))
|
||||||
except NotEnoughFunds as e:
|
except NotEnoughFunds as e:
|
||||||
self.max_button.setChecked(False)
|
self.max_button.setChecked(False)
|
||||||
text = self.wallet.get_text_not_enough_funds_mentioning_frozen()
|
text = self.wallet.get_text_not_enough_funds_mentioning_frozen(for_amount='!')
|
||||||
self.show_error(text)
|
self.show_error(text)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -3417,11 +3417,28 @@ class Abstract_Wallet(ABC, Logger, EventListener):
|
|||||||
def get_unlocked_password(self):
|
def get_unlocked_password(self):
|
||||||
return self._password_in_memory
|
return self._password_in_memory
|
||||||
|
|
||||||
def get_text_not_enough_funds_mentioning_frozen(self) -> str:
|
def get_text_not_enough_funds_mentioning_frozen(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
for_amount: Optional[Union[int, str]] = None,
|
||||||
|
hint: Optional[str] = None
|
||||||
|
) -> str:
|
||||||
|
"""Generate 'Not enough funds' text.
|
||||||
|
Include mention of frozen coins (and append optional hint), iff unfreezing would satisfy for_amount
|
||||||
|
"""
|
||||||
text = _('Not enough funds')
|
text = _('Not enough funds')
|
||||||
frozen_str = self.get_frozen_balance_str()
|
if for_amount is not None:
|
||||||
if frozen_str:
|
if frozen_bal := sum(self.get_frozen_balance()):
|
||||||
text += ' ' + _('({} are frozen)').format(frozen_str)
|
frozen_str = None
|
||||||
|
if isinstance(for_amount, int):
|
||||||
|
if frozen_bal + self.get_spendable_balance_sat() > for_amount:
|
||||||
|
frozen_str = self.config.format_amount_and_units(frozen_bal)
|
||||||
|
elif for_amount == '!':
|
||||||
|
frozen_str = self.config.format_amount_and_units(frozen_bal)
|
||||||
|
if frozen_str:
|
||||||
|
text = _('Not enough funds') + " " + _('({} are frozen)').format(frozen_str)
|
||||||
|
if hint:
|
||||||
|
text += '. ' + hint
|
||||||
return text
|
return text
|
||||||
|
|
||||||
def get_frozen_balance_str(self) -> Optional[str]:
|
def get_frozen_balance_str(self) -> Optional[str]:
|
||||||
|
|||||||
Reference in New Issue
Block a user