Carry ConsensusEncoding(encode::Error)

When psbt::Error was Eq, it could not have associated dyn error types.
This commit is contained in:
DanGould 2023-02-02 12:54:30 -05:00
parent 126cbb00ef
commit 0ffd928a7d
No known key found for this signature in database
GPG Key ID: B07290B28996AFE0
1 changed files with 5 additions and 5 deletions

View File

@ -74,7 +74,7 @@ pub enum Error {
/// global extended public key has inconsistent key sources /// global extended public key has inconsistent key sources
CombineInconsistentKeySources(Box<ExtendedPubKey>), CombineInconsistentKeySources(Box<ExtendedPubKey>),
/// Serialization error in bitcoin consensus-encoded structures /// Serialization error in bitcoin consensus-encoded structures
ConsensusEncoding, ConsensusEncoding(encode::Error),
/// Negative fee /// Negative fee
NegativeFee, NegativeFee,
/// Integer overflow in fee calculation /// Integer overflow in fee calculation
@ -129,7 +129,7 @@ impl fmt::Display for Error {
write!(f, "Preimage {:?} does not match {:?} hash {:?}", preimage, hash_type, hash ) write!(f, "Preimage {:?} does not match {:?} hash {:?}", preimage, hash_type, hash )
}, },
Error::CombineInconsistentKeySources(ref s) => { write!(f, "combine conflict: {}", s) }, Error::CombineInconsistentKeySources(ref s) => { write!(f, "combine conflict: {}", s) },
Error::ConsensusEncoding => f.write_str("bitcoin consensus or BIP-174 encoding error"), Error::ConsensusEncoding(ref e) => write_err!(f, "bitcoin consensus encoding error"; e),
Error::NegativeFee => f.write_str("PSBT has a negative fee which is not allowed"), Error::NegativeFee => f.write_str("PSBT has a negative fee which is not allowed"),
Error::FeeOverflow => f.write_str("integer overflow in fee calculation"), Error::FeeOverflow => f.write_str("integer overflow in fee calculation"),
Error::InvalidPublicKey(ref e) => write_err!(f, "invalid public key"; e), Error::InvalidPublicKey(ref e) => write_err!(f, "invalid public key"; e),
@ -156,6 +156,7 @@ impl std::error::Error for Error {
match self { match self {
HashParse(e) => Some(e), HashParse(e) => Some(e),
ConsensusEncoding(e) => Some(e),
Io(e) => Some(e), Io(e) => Some(e),
| InvalidMagic | InvalidMagic
| MissingUtxo | MissingUtxo
@ -172,7 +173,6 @@ impl std::error::Error for Error {
| NonStandardSighashType(_) | NonStandardSighashType(_)
| InvalidPreimageHashPair{ .. } | InvalidPreimageHashPair{ .. }
| CombineInconsistentKeySources(_) | CombineInconsistentKeySources(_)
| ConsensusEncoding
| NegativeFee | NegativeFee
| FeeOverflow | FeeOverflow
| InvalidPublicKey(_) | InvalidPublicKey(_)
@ -198,8 +198,8 @@ impl From<hashes::Error> for Error {
} }
impl From<encode::Error> for Error { impl From<encode::Error> for Error {
fn from(_: encode::Error) -> Self { fn from(e: encode::Error) -> Self {
Error::ConsensusEncoding Error::ConsensusEncoding(e)
} }
} }