bip21: consider amount=0 in bip21 uri invalid
This commit is contained in:
@@ -61,7 +61,7 @@ def parse_bip21_URI(uri: str) -> dict:
|
|||||||
amount = Decimal(m.group(1)) * pow(Decimal(10), k)
|
amount = Decimal(m.group(1)) * pow(Decimal(10), k)
|
||||||
else:
|
else:
|
||||||
amount = Decimal(am) * COIN
|
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")
|
raise InvalidBitcoinURI(f"amount is out-of-bounds: {amount!r} BTC")
|
||||||
out['amount'] = int(amount)
|
out['amount'] = int(amount)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -92,7 +92,7 @@ def parse_bip21_URI(uri: str) -> dict:
|
|||||||
amount_sat = out.get('amount')
|
amount_sat = out.get('amount')
|
||||||
if amount_sat:
|
if amount_sat:
|
||||||
# allow small leeway due to msat precision
|
# 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")
|
raise InvalidBitcoinURI("Inconsistent lightning field in bip21: amount")
|
||||||
address = out.get('address')
|
address = out.get('address')
|
||||||
ln_fallback_addr = lnaddr.get_fallback_address()
|
ln_fallback_addr = lnaddr.get_fallback_address()
|
||||||
|
|||||||
Reference in New Issue
Block a user