Qt: add bolt11_fallback and bip21_lightning options to preferences
This commit is contained in:
@@ -1268,11 +1268,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||
|
||||
def show_receive_request(self, req):
|
||||
addr = req.get_address() or ''
|
||||
URI = req.get_bip21_URI() if addr else ''
|
||||
lnaddr = req.lightning_invoice or ''
|
||||
can_receive_lightning = self.wallet.lnworker and req.get_amount_sat() <= self.wallet.lnworker.num_sats_can_receive()
|
||||
if not can_receive_lightning:
|
||||
lnaddr = ''
|
||||
lnaddr = req.lightning_invoice if can_receive_lightning else None
|
||||
bip21_lightning = lnaddr if self.config.get('bip21_lightning', False) else None
|
||||
URI = req.get_bip21_URI(lightning=bip21_lightning)
|
||||
lnaddr = lnaddr or ''
|
||||
icon_name = "lightning.png" if can_receive_lightning else "lightning_disconnected.png"
|
||||
self.receive_tabs.setTabIcon(2, read_QIcon(icon_name))
|
||||
# encode lightning invoices as uppercase so QR encoding can use
|
||||
@@ -1673,7 +1673,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||
choices = {}
|
||||
if can_pay_onchain:
|
||||
msg = ''.join([
|
||||
_('Pay this invoice onchain'), '\n',
|
||||
_('Pay onchain'), '\n',
|
||||
_('Funds will be sent to the invoice fallback address.')
|
||||
])
|
||||
choices[0] = msg
|
||||
@@ -1694,7 +1694,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||
msg = _('You cannot pay that invoice using Lightning.')
|
||||
if self.wallet.lnworker.channels:
|
||||
msg += '\n' + _('Your channels can send {}.').format(self.format_amount(num_sats_can_send) + self.base_unit())
|
||||
|
||||
r = self.query_choice(msg, choices)
|
||||
if r is not None:
|
||||
self.save_pending_invoice()
|
||||
@@ -2162,6 +2161,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||
amount = out.get('amount')
|
||||
label = out.get('label')
|
||||
message = out.get('message')
|
||||
lightning = out.get('lightning')
|
||||
if lightning:
|
||||
self.set_ln_invoice(lightning)
|
||||
return
|
||||
# use label as description (not BIP21 compliant)
|
||||
if label and not message:
|
||||
message = label
|
||||
|
||||
@@ -97,6 +97,21 @@ class SettingsDialog(WindowModalDialog):
|
||||
self.window.refresh_tabs()
|
||||
nz.valueChanged.connect(on_nz)
|
||||
|
||||
# invoices
|
||||
bolt11_fallback_cb = QCheckBox(_('Add on-chain fallback to lightning invoices'))
|
||||
bolt11_fallback_cb.setChecked(bool(self.config.get('bolt11_fallback', True)))
|
||||
bolt11_fallback_cb.setToolTip(_('Add fallback addresses to BOLT11 lightning invoices.'))
|
||||
def on_bolt11_fallback(x):
|
||||
self.config.set_key('bolt11_fallback', bool(x))
|
||||
bolt11_fallback_cb.stateChanged.connect(on_bolt11_fallback)
|
||||
|
||||
bip21_lightning_cb = QCheckBox(_('Add lightning invoice to bitcoin URIs'))
|
||||
bip21_lightning_cb.setChecked(bool(self.config.get('bip21_lightning', False)))
|
||||
bip21_lightning_cb.setToolTip(_('This may create larger qr codes.'))
|
||||
def on_bip21_lightning(x):
|
||||
self.config.set_key('bip21_lightning', bool(x))
|
||||
bip21_lightning_cb.stateChanged.connect(on_bip21_lightning)
|
||||
|
||||
use_rbf = bool(self.config.get('use_rbf', True))
|
||||
use_rbf_cb = QCheckBox(_('Use Replace-By-Fee'))
|
||||
use_rbf_cb.setChecked(use_rbf)
|
||||
@@ -483,6 +498,9 @@ class SettingsDialog(WindowModalDialog):
|
||||
gui_widgets.append((nz_label, nz))
|
||||
gui_widgets.append((msat_cb, None))
|
||||
gui_widgets.append((thousandsep_cb, None))
|
||||
invoices_widgets = []
|
||||
invoices_widgets.append((bolt11_fallback_cb, None))
|
||||
invoices_widgets.append((bip21_lightning_cb, None))
|
||||
tx_widgets = []
|
||||
tx_widgets.append((usechange_cb, None))
|
||||
tx_widgets.append((use_rbf_cb, None))
|
||||
@@ -513,6 +531,7 @@ class SettingsDialog(WindowModalDialog):
|
||||
|
||||
tabs_info = [
|
||||
(gui_widgets, _('Appearance')),
|
||||
(invoices_widgets, _('Invoices')),
|
||||
(tx_widgets, _('Transactions')),
|
||||
(lightning_widgets, _('Lightning')),
|
||||
(fiat_widgets, _('Fiat')),
|
||||
|
||||
Reference in New Issue
Block a user