qt: follow-up LN/onchain req sep: consistent URI/bolt11 errors
- if we show error for LN request, we should also show error for LN-only bip21 URI
follow-up af0ac40478
- for LN request, show better error msg if don't have any channels
closes https://github.com/spesmilo/electrum/issues/9413
note: would be nice if qml GUI could reuse this logic (wallet.get_help_texts_for_receive_request)
This commit is contained in:
@@ -3282,6 +3282,9 @@ class Abstract_Wallet(ABC, Logger, EventListener):
|
||||
ln_swap_suggestion = None
|
||||
ln_rebalance_suggestion = None
|
||||
URI = self.get_request_URI(req) or ''
|
||||
lightning_has_channels = (
|
||||
self.lnworker and len([chan for chan in self.lnworker.channels.values() if chan.is_open()]) > 0
|
||||
)
|
||||
lightning_online = self.lnworker and self.lnworker.num_peers() > 0
|
||||
can_receive_lightning = self.lnworker and amount_sat <= self.lnworker.num_sats_can_receive()
|
||||
status = self.get_invoice_status(req)
|
||||
@@ -3309,7 +3312,10 @@ class Abstract_Wallet(ABC, Logger, EventListener):
|
||||
address_help = URI_help = (_("This address has already been used. "
|
||||
"For better privacy, do not reuse it for new payments."))
|
||||
if req.is_lightning():
|
||||
if not lightning_online:
|
||||
if not lightning_has_channels:
|
||||
ln_is_error = True
|
||||
ln_help = _("You must have an open Lightning channel to receive payments.")
|
||||
elif not lightning_online:
|
||||
ln_is_error = True
|
||||
ln_help = _('You must be online to receive Lightning payments.')
|
||||
elif not can_receive_lightning:
|
||||
@@ -3321,6 +3327,10 @@ class Abstract_Wallet(ABC, Logger, EventListener):
|
||||
ln_help += '\n\n' + _('You may have that capacity if you rebalance your channels.')
|
||||
elif bool(ln_swap_suggestion):
|
||||
ln_help += '\n\n' + _('You may have that capacity if you swap some of your funds.')
|
||||
# for URI that has LN part but no onchain part, copy error:
|
||||
if not addr and ln_is_error:
|
||||
URI_is_error = ln_is_error
|
||||
URI_help = ln_help
|
||||
return ReceiveRequestHelp(
|
||||
address_help=address_help,
|
||||
URI_help=URI_help,
|
||||
|
||||
Reference in New Issue
Block a user