diff --git a/bip-0328/_xpub.py b/bip-0328/_xpub.py index 004b5933ef..55917063f6 100644 --- a/bip-0328/_xpub.py +++ b/bip-0328/_xpub.py @@ -133,7 +133,9 @@ def deserialize(cls, xpub: str) -> 'ExtendedKey': :param xpub: The Base58 check encoded xpub """ - data = base58.decode(xpub)[:-4] # Decoded xpub without checksum + data = base58.decode_check(xpub) + if len(data) != 78: # BIP32 Serialization Format defines a 78-byte structure. + raise ValueError("Invalid extended key length") return cls.from_bytes(data) @classmethod