From 1495040f45c0487226e93c97004ef555aa75d794 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Tue, 23 Jun 2020 15:38:06 +0200 Subject: [PATCH] lnworker._check_invoice: add sanity check --- electrum/lnworker.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/electrum/lnworker.py b/electrum/lnworker.py index 471ac5f63..8641367e0 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -1002,7 +1002,10 @@ class LNWallet(LNWorker): addr = lndecode(invoice, expected_hrp=constants.net.SEGWIT_HRP) if addr.is_expired(): raise InvoiceError(_("This invoice has expired")) - if amount_msat: + if amount_msat: # replace amt in invoice. main usecase is paying zero amt invoices + existing_amt_msat = addr.get_amount_msat() + if existing_amt_msat and amount_msat < existing_amt_msat: + raise Exception("cannot pay lower amt than what is originally in LN invoice") addr.amount = Decimal(amount_msat) / COIN / 1000 if addr.amount is None: raise InvoiceError(_("Missing amount"))