File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77from . import bitcoin
88from .util import format_satoshis_plain
99from .bitcoin import COIN , TOTAL_COIN_SUPPLY_LIMIT_IN_BTC
10- from .bolt11 import decode_bolt11_invoice , BOLT11DecodeException
10+ from .bolt11 import decode_bolt11_invoice , BOLT11InvoiceException
1111
1212# note: when checking against these, use .lower() to support case-insensitivity
1313BITCOIN_BIP21_URI_SCHEME = 'bitcoin'
@@ -35,7 +35,11 @@ def parse_bip21_URI(uri: str) -> dict:
3535 raise InvalidBitcoinURI ("Not a bitcoin address" )
3636 return {'address' : uri }
3737
38- u = urllib .parse .urlparse (uri )
38+ try :
39+ u = urllib .parse .urlparse (uri )
40+ except ValueError as e :
41+ raise InvalidBitcoinURI ("failed to parse uri" ) from e
42+
3943 if u .scheme .lower () != BITCOIN_BIP21_URI_SCHEME :
4044 raise InvalidBitcoinURI ("Not a bitcoin URI" )
4145 address = u .path
@@ -94,7 +98,7 @@ def parse_bip21_URI(uri: str) -> dict:
9498 if 'lightning' in out :
9599 try :
96100 lnaddr = decode_bolt11_invoice (out ['lightning' ])
97- except BOLT11DecodeException as e :
101+ except BOLT11InvoiceException as e :
98102 raise InvalidBitcoinURI (f"Failed to decode 'lightning' field: { e !r} " ) from e
99103 amount_sat = out .get ('amount' )
100104 if amount_sat :
You can’t perform that action at this time.
0 commit comments