[docs]class KeyParseError(Exception):
pass
[docs]class ChecksumException(Exception):
"""
Raised when the generated checksum of an address or public key
does not match the expected checksum.
"""
[docs]class IncompatibleNetworkException(Exception):
"""
Raised when importing a piece of network data
into the wrong network.
"""
[docs]class InvalidChildException(Exception):
"""
Raised when an invalid child key is passed.
"""
[docs]class WatchOnlyWalletError(Exception):
"""
Raised when a wallet does not contain a private key when
performing an operation that requires a public key.
"""
[docs]class SegwitError(Exception):
"""
Raised when a network does not support Segwit (P2WPKH).
"""
[docs]class InvalidPathError(Exception):
"""
Raised when the provided derivation path is invalid.
"""
[docs]class NetworkException(Exception):
"""
Raised when a network request fails.
"""
[docs]class PublicKeyHashException(Exception):
"""
Raised when attempting a public key operation with a public key hash.
"""
[docs]def incompatible_network_bytes_exception_factory(
network_name, expected_prefix, given_prefix
):
"""A factory function for IncompatibleNetworkException."""
return IncompatibleNetworkException(
f"Incorrect network. {network_name} expects a byte prefix of "
f"{expected_prefix}, but you supplied {given_prefix}"
)
[docs]def unsupported_feature_exception_factory(network_name, feature):
"""Another factory function for IncompatibleNetworkException."""
return IncompatibleNetworkException(
f"{network_name} does not support feature: {feature}"
)