Browse Source

lnworker._check_invoice: add sanity check

bip39-recovery
SomberNight 5 years ago
parent
commit
1495040f45
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 5
      electrum/lnworker.py

5
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"))

Loading…
Cancel
Save