Fallback addresses
- add fallback address to BOLT-11 LN invoices - Qt: if LN payment fails, propose onchain fallback
This commit is contained in:
@@ -1698,7 +1698,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
||||
|
||||
def on_payment_failed(self, wallet, key, reason):
|
||||
invoice = self.wallet.get_invoice(key)
|
||||
self.show_error(_('Payment failed') + '\n\n' + reason)
|
||||
if invoice and invoice.is_lightning() and invoice.get_address():
|
||||
if self.question(_('Payment failed') + '\n\n' + reason + '\n\n'+ 'Fallback to onchain payment?'):
|
||||
self.pay_onchain_dialog(self.get_coins(), invoice.get_outputs())
|
||||
else:
|
||||
self.show_error(_('Payment failed') + '\n\n' + reason)
|
||||
|
||||
def read_invoice(self):
|
||||
if self.check_send_tab_payto_line_and_show_errors():
|
||||
|
||||
@@ -1742,6 +1742,7 @@ class LNWallet(LNWorker):
|
||||
amount_msat: Optional[int],
|
||||
message: str,
|
||||
expiry: int,
|
||||
fallback_address: str,
|
||||
write_to_disk: bool = True,
|
||||
) -> Tuple[LnAddr, str]:
|
||||
|
||||
@@ -1771,7 +1772,9 @@ class LNWallet(LNWorker):
|
||||
('d', message),
|
||||
('c', MIN_FINAL_CLTV_EXPIRY_FOR_INVOICE),
|
||||
('x', expiry),
|
||||
('9', invoice_features)]
|
||||
('9', invoice_features),
|
||||
('f', fallback_address),
|
||||
]
|
||||
+ routing_hints
|
||||
+ trampoline_hints,
|
||||
date=timestamp,
|
||||
@@ -1783,7 +1786,7 @@ class LNWallet(LNWorker):
|
||||
self.wallet.save_db()
|
||||
return lnaddr, invoice
|
||||
|
||||
def add_request(self, amount_sat: Optional[int], message, expiry: int) -> str:
|
||||
def add_request(self, amount_sat: Optional[int], message:str, expiry: int, fallback_address:str) -> str:
|
||||
# passed expiry is relative, it is absolute in the lightning invoice
|
||||
amount_msat = amount_sat * 1000 if amount_sat is not None else None
|
||||
timestamp = int(time.time())
|
||||
@@ -1791,6 +1794,7 @@ class LNWallet(LNWorker):
|
||||
amount_msat=amount_msat,
|
||||
message=message,
|
||||
expiry=expiry,
|
||||
fallback_address=fallback_address,
|
||||
write_to_disk=False,
|
||||
)
|
||||
return invoice
|
||||
|
||||
Reference in New Issue
Block a user