qt,qml: move get_text_not_enough_funds_mentioning_frozen and get_frozen_balance_str to backend wallet
Note: the qt gui used to include FX in get_frozen_balance_str, but that is not replicated now.
This commit is contained in:
@@ -230,9 +230,9 @@ ElDialog {
|
||||
Connections {
|
||||
target: invoice.amountOverride
|
||||
function onSatsIntChanged() {
|
||||
console.log('amuontOverride satsIntChanged, sats=' + invoice.amountOverride.satsInt)
|
||||
console.log('amountOverride satsIntChanged, sats=' + invoice.amountOverride.satsInt)
|
||||
if (amountMax.checked) // amountOverride updated by max amount estimate
|
||||
amountBtc.text = Config.formatSats(invoice.amountOverride.satsInt)
|
||||
amountBtc.text = Config.formatSatsForEditing(invoice.amountOverride.satsInt)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ ElDialog {
|
||||
target: channelopener.amount
|
||||
function onSatsIntChanged() {
|
||||
if (is_max.checked) // amount updated by max amount estimate
|
||||
amountBtc.text = Config.formatSats(channelopener.amount.satsInt)
|
||||
amountBtc.text = Config.formatSatsForEditing(channelopener.amount.satsInt)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -819,20 +819,8 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
||||
sig = self.wallet.sign_message(address, message, self.password)
|
||||
return base64.b64encode(sig).decode('ascii')
|
||||
|
||||
def get_text_not_enough_funds_mentioning_frozen(self) -> str:
|
||||
text = _('Not enough funds')
|
||||
frozen_str = self.get_frozen_balance_str()
|
||||
if frozen_str:
|
||||
text += " ({} {})".format(frozen_str, _('are frozen'))
|
||||
return text
|
||||
|
||||
def get_frozen_balance_str(self) -> Optional[str]:
|
||||
frozen_bal = sum(self.wallet.get_frozen_balance())
|
||||
if not frozen_bal:
|
||||
return None
|
||||
return self.wallet.config.format_amount_and_units(frozen_bal)
|
||||
|
||||
def determine_max(self, *, mktx: Callable[[int], PartialTransaction]) -> Tuple[int, str]:
|
||||
def determine_max(self, *, mktx: Callable[[Optional[int]], PartialTransaction]) -> Tuple[Optional[int], Optional[str]]:
|
||||
# TODO: merge with SendTab.spend_max() and move to backend wallet
|
||||
amount = message = None
|
||||
try:
|
||||
try:
|
||||
@@ -844,6 +832,6 @@ class QEWallet(AuthMixin, QObject, QtEventListener):
|
||||
amount = tx.output_value()
|
||||
except NotEnoughFunds as e:
|
||||
self._logger.debug(str(e))
|
||||
message = self.get_text_not_enough_funds_mentioning_frozen()
|
||||
message = self.wallet.get_text_not_enough_funds_mentioning_frozen()
|
||||
|
||||
return amount, message
|
||||
|
||||
@@ -267,7 +267,7 @@ class SendTab(QWidget, MessageBoxMixin, Logger):
|
||||
tx = make_tx(0)
|
||||
except NotEnoughFunds as e:
|
||||
self.max_button.setChecked(False)
|
||||
text = self.get_text_not_enough_funds_mentioning_frozen()
|
||||
text = self.wallet.get_text_not_enough_funds_mentioning_frozen()
|
||||
self.show_error(text)
|
||||
return
|
||||
|
||||
@@ -283,7 +283,7 @@ class SendTab(QWidget, MessageBoxMixin, Logger):
|
||||
if x_fee_amount:
|
||||
twofactor_fee_str = self.format_amount_and_units(x_fee_amount)
|
||||
msg += "\n" + _("2fa fee: {} (for the next batch of transactions)").format(twofactor_fee_str)
|
||||
frozen_bal = self.get_frozen_balance_str()
|
||||
frozen_bal = self.wallet.get_frozen_balance_str()
|
||||
if frozen_bal:
|
||||
msg += "\n" + _("Some coins are frozen: {} (can be unfrozen in the Addresses or in the Coins tab)").format(frozen_bal)
|
||||
QToolTip.showText(self.max_button.mapToGlobal(QPoint(0, 0)), msg)
|
||||
@@ -353,19 +353,6 @@ class SendTab(QWidget, MessageBoxMixin, Logger):
|
||||
callback=sign_done,
|
||||
external_keypairs=external_keypairs)
|
||||
|
||||
def get_text_not_enough_funds_mentioning_frozen(self) -> str:
|
||||
text = _("Not enough funds")
|
||||
frozen_str = self.get_frozen_balance_str()
|
||||
if frozen_str:
|
||||
text += " ({} {})".format(frozen_str, _("are frozen"))
|
||||
return text
|
||||
|
||||
def get_frozen_balance_str(self) -> Optional[str]:
|
||||
frozen_bal = sum(self.wallet.get_frozen_balance())
|
||||
if not frozen_bal:
|
||||
return None
|
||||
return self.format_amount_and_units(frozen_bal)
|
||||
|
||||
def do_clear(self):
|
||||
self.logger.debug('do_clear')
|
||||
self.lock_fields(lock_recipient=False, lock_amount=False, lock_max=True, lock_description=False)
|
||||
|
||||
@@ -3356,6 +3356,19 @@ class Abstract_Wallet(ABC, Logger, EventListener):
|
||||
def get_unlocked_password(self):
|
||||
return self._password_in_memory
|
||||
|
||||
def get_text_not_enough_funds_mentioning_frozen(self) -> str:
|
||||
text = _('Not enough funds')
|
||||
frozen_str = self.get_frozen_balance_str()
|
||||
if frozen_str:
|
||||
text += ' ' + _('({} are frozen)').format(frozen_str)
|
||||
return text
|
||||
|
||||
def get_frozen_balance_str(self) -> Optional[str]:
|
||||
frozen_bal = sum(self.get_frozen_balance())
|
||||
if not frozen_bal:
|
||||
return None
|
||||
return self.config.format_amount_and_units(frozen_bal)
|
||||
|
||||
|
||||
class Simple_Wallet(Abstract_Wallet):
|
||||
# wallet with a single keystore
|
||||
|
||||
Reference in New Issue
Block a user