Merge pull request #9941 from f321x/fix_bolt11_pi_exceptions
fix: handle ! amount for payment identifiers more gracefully
This commit is contained in:
@@ -242,9 +242,11 @@ class SendTab(QWidget, MessageBoxMixin, Logger):
|
|||||||
|
|
||||||
if pi is None or pi.type == PaymentIdentifierType.UNKNOWN:
|
if pi is None or pi.type == PaymentIdentifierType.UNKNOWN:
|
||||||
return
|
return
|
||||||
|
elif pi.type not in [PaymentIdentifierType.SPK, PaymentIdentifierType.MULTILINE,
|
||||||
assert pi.type in [PaymentIdentifierType.SPK, PaymentIdentifierType.MULTILINE,
|
PaymentIdentifierType.BIP21, PaymentIdentifierType.OPENALIAS]:
|
||||||
PaymentIdentifierType.BIP21, PaymentIdentifierType.OPENALIAS]
|
# clear the amount field once it is clear this PI is not eligible for '!'
|
||||||
|
self.amount_e.clear()
|
||||||
|
return
|
||||||
|
|
||||||
if pi.type == PaymentIdentifierType.BIP21:
|
if pi.type == PaymentIdentifierType.BIP21:
|
||||||
assert 'amount' not in pi.bip21
|
assert 'amount' not in pi.bip21
|
||||||
@@ -406,6 +408,8 @@ class SendTab(QWidget, MessageBoxMixin, Logger):
|
|||||||
self.amount_e.setFrozen(lock_amount)
|
self.amount_e.setFrozen(lock_amount)
|
||||||
if lock_max is not None:
|
if lock_max is not None:
|
||||||
self.max_button.setEnabled(not lock_max)
|
self.max_button.setEnabled(not lock_max)
|
||||||
|
if lock_max is True:
|
||||||
|
self.max_button.setChecked(False)
|
||||||
if lock_description is not None:
|
if lock_description is not None:
|
||||||
self.message_e.setFrozen(lock_description)
|
self.message_e.setFrozen(lock_description)
|
||||||
|
|
||||||
@@ -466,6 +470,8 @@ class SendTab(QWidget, MessageBoxMixin, Logger):
|
|||||||
# resolve '!' in amount editor if it was set before PI
|
# resolve '!' in amount editor if it was set before PI
|
||||||
if not lock_max and self.amount_e.text() == '!':
|
if not lock_max and self.amount_e.text() == '!':
|
||||||
self.spend_max()
|
self.spend_max()
|
||||||
|
elif lock_max and self.amount_e.text() == '!':
|
||||||
|
self.amount_e.clear()
|
||||||
|
|
||||||
pi_unusable = pi.is_error() or (not self.wallet.has_lightning() and not pi.is_onchain())
|
pi_unusable = pi.is_error() or (not self.wallet.has_lightning() and not pi.is_onchain())
|
||||||
is_spk_script = pi.type == PaymentIdentifierType.SPK and not pi.spk_is_address
|
is_spk_script = pi.type == PaymentIdentifierType.SPK and not pi.spk_is_address
|
||||||
|
|||||||
Reference in New Issue
Block a user