Skip to content

Commit f87cb18

Browse files
committed
Add: update p2pkh-address exceptions
1 parent 8b9b460 commit f87cb18

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

bip38/p2pkh_address.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from .secp256k1 import PublicKey
1515
from .cryptocurrencies import Bitcoin
1616
from .crypto import hash160
17+
from .exceptions import AddressError
1718
from .utils import (
1819
get_bytes, integer_to_bytes, bytes_to_string
1920
)
@@ -87,10 +88,10 @@ def decode(cls, address: str, **kwargs: Any) -> str:
8788

8889
expected_length: int = 20 + len(address_prefix)
8990
if len(address_decode) != expected_length:
90-
raise ValueError(f"Invalid length (expected: {expected_length}, got: {len(address_decode)})")
91+
raise AddressError(f"Invalid length (expected: {expected_length}, got: {len(address_decode)})")
9192

9293
prefix_got: bytes = address_decode[:len(address_prefix)]
9394
if address_prefix != prefix_got:
94-
raise ValueError(f"Invalid prefix (expected: {address_prefix}, got: {prefix_got})")
95+
raise AddressError(f"Invalid prefix (expected: {address_prefix}, got: {prefix_got})")
9596

9697
return bytes_to_string(address_decode[len(address_prefix):])

0 commit comments

Comments
 (0)