diff --git a/electrum/gui/qt/main_window.py b/electrum/gui/qt/main_window.py index 3833728c8..779fb08a1 100644 --- a/electrum/gui/qt/main_window.py +++ b/electrum/gui/qt/main_window.py @@ -1390,8 +1390,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): return False # no errors - def pay_lightning_invoice(self, invoice): - amount_sat = self.amount_e.get_amount() + def pay_lightning_invoice(self, invoice, amount_sat=None): attempts = LN_NUM_PAYMENT_ATTEMPTS def task(): self.wallet.lnworker.pay(invoice, amount_sat, attempts) @@ -1469,7 +1468,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger): def do_pay_invoice(self, invoice): if invoice['type'] == PR_TYPE_LN: - self.pay_lightning_invoice(invoice['invoice']) + self.pay_lightning_invoice(invoice['invoice'], amount_sat=invoice['amount']) elif invoice['type'] == PR_TYPE_ONCHAIN: outputs = invoice['outputs'] self.pay_onchain_dialog(self.get_coins(), outputs, invoice=invoice) diff --git a/electrum/lnworker.py b/electrum/lnworker.py index 9ef35c780..144340099 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -845,10 +845,10 @@ class LNWallet(LNWorker): @log_exceptions async def _pay(self, invoice, amount_sat=None, attempts=1): - lnaddr = lndecode(invoice, expected_hrp=constants.net.SEGWIT_HRP) + lnaddr = self._check_invoice(invoice, amount_sat) payment_hash = lnaddr.paymenthash key = payment_hash.hex() - amount = int(lnaddr.amount * COIN) if lnaddr.amount else None + amount = int(lnaddr.amount * COIN) status = self.get_payment_status(payment_hash) if status == PR_PAID: raise PaymentFailure(_("This invoice has been paid already")) @@ -856,7 +856,6 @@ class LNWallet(LNWorker): raise PaymentFailure(_("A payment was already initiated for this invoice")) info = PaymentInfo(lnaddr.paymenthash, amount, SENT, PR_UNPAID) self.save_payment_info(info) - self._check_invoice(invoice, amount_sat) self.wallet.set_label(key, lnaddr.get_description()) log = self.logs[key] for i in range(attempts):