Use defensive documentation

Only commit in the docs and error messages to what we _really_ know.

In an attempt to reduce the likelyhood of the code going stale only
commit to what is guaranteed - that we have an error from a module.

This does arguably reduce the amount of context around the error.
This commit is contained in:
Tobin C. Harding 2023-05-18 16:19:37 +10:00
parent 80d5d6665a
commit 3225aa9556
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
3 changed files with 10 additions and 11 deletions

View File

@ -192,7 +192,7 @@ pub enum Error {
SighashType(NonStandardSighashTypeError),
/// Empty Signature
EmptySignature,
/// secp256k1-related error
/// A secp256k1 error
Secp256k1(secp256k1::Error),
}
@ -204,7 +204,7 @@ impl fmt::Display for Error {
Hex(ref e) => write_err!(f, "signature hex decoding error"; e),
SighashType(ref e) => write_err!(f, "non-standard signature hash type"; e),
EmptySignature => write!(f, "empty ECDSA signature"),
Secp256k1(ref e) => write_err!(f, "invalid ECDSA signature"; e),
Secp256k1(ref e) => write_err!(f, "secp256k1"; e),
}
}
}

View File

@ -679,9 +679,9 @@ impl From<TweakedKeyPair> for TweakedPublicKey {
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum Error {
/// Base58 encoding error
/// A base58 error.
Base58(base58::Error),
/// secp256k1-related error
/// A secp256k1 error.
Secp256k1(secp256k1::Error),
/// Invalid key prefix error
InvalidKeyPrefix(u8),
@ -696,10 +696,10 @@ impl fmt::Display for Error {
use Error::*;
match *self {
Base58(ref e) => write_err!(f, "key base58 error"; e),
Secp256k1(ref e) => write_err!(f, "key secp256k1 error"; e),
Base58(ref e) => write_err!(f, "base58"; e),
Secp256k1(ref e) => write_err!(f, "secp256k1"; e),
InvalidKeyPrefix(ref b) => write!(f, "key prefix invalid: {}", b),
Hex(ref e) => write_err!(f, "key hex decoding error"; e),
Hex(ref e) => write_err!(f, "hex"; e),
InvalidHexLength(got) =>
write!(f, "pubkey hex should be 66 or 130 digits long, got: {}", got),
}

View File

@ -64,7 +64,7 @@ impl Signature {
pub enum SigFromSliceError {
/// Invalid signature hash type.
SighashType(InvalidSighashTypeError),
/// Signature has valid size but does not parse correctly
/// A secp256k1 error.
Secp256k1(secp256k1::Error),
/// Invalid taproot signature size
InvalidSignatureSize(usize),
@ -75,9 +75,8 @@ impl fmt::Display for SigFromSliceError {
use SigFromSliceError::*;
match *self {
SighashType(ref e) => write_err!(f, "invalid signature hash type"; e),
Secp256k1(ref e) =>
write_err!(f, "taproot signature has correct len but is malformed"; e),
SighashType(ref e) => write_err!(f, "sighash"; e),
Secp256k1(ref e) => write_err!(f, "secp256k1"; e),
InvalidSignatureSize(sz) => write!(f, "invalid taproot signature size: {}", sz),
}
}