Browse Source

bip21: consider amount=0 in bip21 uri invalid

master
Sander van Grieken 2 years ago
parent
commit
bb4ee2b50b
No known key found for this signature in database
GPG Key ID: 9BCF8209EA402EBA
  1. 4
      electrum/bip21.py

4
electrum/bip21.py

@ -61,7 +61,7 @@ def parse_bip21_URI(uri: str) -> dict:
amount = Decimal(m.group(1)) * pow(Decimal(10), k)
else:
amount = Decimal(am) * COIN
if amount > TOTAL_COIN_SUPPLY_LIMIT_IN_BTC * COIN:
if amount > TOTAL_COIN_SUPPLY_LIMIT_IN_BTC * COIN or amount <= 0:
raise InvalidBitcoinURI(f"amount is out-of-bounds: {amount!r} BTC")
out['amount'] = int(amount)
except Exception as e:
@ -92,7 +92,7 @@ def parse_bip21_URI(uri: str) -> dict:
amount_sat = out.get('amount')
if amount_sat:
# allow small leeway due to msat precision
if abs(amount_sat - int(lnaddr.get_amount_sat())) > 1:
if lnaddr.get_amount_msat() is None or abs(amount_sat - int(lnaddr.get_amount_sat())) > 1:
raise InvalidBitcoinURI("Inconsistent lightning field in bip21: amount")
address = out.get('address')
ln_fallback_addr = lnaddr.get_fallback_address()

Loading…
Cancel
Save