bip32: remove unused error variants

This commit is contained in:
Andrew Poelstra 2025-04-21 22:30:35 +00:00
parent f0a237c001
commit a891fb9b74
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 1 additions and 14 deletions

View File

@ -503,18 +503,12 @@ pub enum Error {
InvalidChildNumber(u32), InvalidChildNumber(u32),
/// Invalid childnumber format. /// Invalid childnumber format.
InvalidChildNumberFormat, InvalidChildNumberFormat,
/// Invalid derivation path format.
InvalidDerivationPathFormat,
/// Unknown version magic bytes /// Unknown version magic bytes
UnknownVersion([u8; 4]), UnknownVersion([u8; 4]),
/// Encoded extended key data has wrong length /// Encoded extended key data has wrong length
WrongExtendedKeyLength(usize), WrongExtendedKeyLength(usize),
/// Base58 encoding error /// Base58 encoding error
Base58(base58::Error), Base58(base58::Error),
/// Hexadecimal decoding error
Hex(hex::HexToArrayError),
/// `PublicKey` hex should be 66 or 130 digits long.
InvalidPublicKeyHexLength(usize),
/// Base58 decoded data was an invalid length. /// Base58 decoded data was an invalid length.
InvalidBase58PayloadLength(InvalidBase58PayloadLengthError), InvalidBase58PayloadLength(InvalidBase58PayloadLengthError),
/// Invalid private key prefix (byte 45 must be 0) /// Invalid private key prefix (byte 45 must be 0)
@ -538,14 +532,10 @@ impl fmt::Display for Error {
InvalidChildNumber(ref n) => InvalidChildNumber(ref n) =>
write!(f, "child number {} is invalid (not within [0, 2^31 - 1])", n), write!(f, "child number {} is invalid (not within [0, 2^31 - 1])", n),
InvalidChildNumberFormat => f.write_str("invalid child number format"), InvalidChildNumberFormat => f.write_str("invalid child number format"),
InvalidDerivationPathFormat => f.write_str("invalid derivation path format"),
UnknownVersion(ref bytes) => write!(f, "unknown version magic bytes: {:?}", bytes), UnknownVersion(ref bytes) => write!(f, "unknown version magic bytes: {:?}", bytes),
WrongExtendedKeyLength(ref len) => WrongExtendedKeyLength(ref len) =>
write!(f, "encoded extended key data has wrong length {}", len), write!(f, "encoded extended key data has wrong length {}", len),
Base58(ref e) => write_err!(f, "base58 encoding error"; e), Base58(ref e) => write_err!(f, "base58 encoding error"; e),
Hex(ref e) => write_err!(f, "Hexadecimal decoding error"; e),
InvalidPublicKeyHexLength(got) =>
write!(f, "PublicKey hex should be 66 or 130 digits long, got: {}", got),
InvalidBase58PayloadLength(ref e) => write_err!(f, "base58 payload"; e), InvalidBase58PayloadLength(ref e) => write_err!(f, "base58 payload"; e),
InvalidPrivateKeyPrefix => InvalidPrivateKeyPrefix =>
f.write_str("invalid private key prefix, byte 45 must be 0 as required by BIP-32"), f.write_str("invalid private key prefix, byte 45 must be 0 as required by BIP-32"),
@ -564,14 +554,11 @@ impl std::error::Error for Error {
match *self { match *self {
Secp256k1(ref e) => Some(e), Secp256k1(ref e) => Some(e),
Base58(ref e) => Some(e), Base58(ref e) => Some(e),
Hex(ref e) => Some(e),
InvalidBase58PayloadLength(ref e) => Some(e), InvalidBase58PayloadLength(ref e) => Some(e),
InvalidChildNumber(_) InvalidChildNumber(_)
| InvalidChildNumberFormat | InvalidChildNumberFormat
| InvalidDerivationPathFormat
| UnknownVersion(_) | UnknownVersion(_)
| WrongExtendedKeyLength(_) | WrongExtendedKeyLength(_) => None,
| InvalidPublicKeyHexLength(_) => None,
InvalidPrivateKeyPrefix => None, InvalidPrivateKeyPrefix => None,
NonZeroParentFingerprintForMasterKey => None, NonZeroParentFingerprintForMasterKey => None,
NonZeroChildNumberForMasterKey => None, NonZeroChildNumberForMasterKey => None,