def METHOD_NAME(xpub: str) -> messages.HDNodeType:
    data = tools.b58decode(xpub, None)
    if tools.btc_hash(data[:-4])[:4] != data[-4:]:
        raise ValueError("Checksum failed")
    node = messages.HDNodeType(
        depth=struct.unpack(">B", data[4:5])[0],
        fingerprint=struct.unpack(">I", data[5:9])[0],
        child_num=struct.unpack(">I", data[9:13])[0],
        chain_code=data[13:45],
        public_key=None,
    )
    key = data[45:-4]
    if key[0] == 0:
        node.private_key = key[1:]
    else:
        node.public_key = key
    return node