diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py index d1cf075f6..408794caf 100644 --- a/electrum/gui/qt/main_window.py +++ b/electrum/gui/qt/main_window.py @@ -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(): diff --git a/electrum/lnworker.py b/electrum/lnworker.py index bd94cce3e..f59e32fef 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -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