From 0ffd928a7df9aa4243fe454a32557f02a8e1a8c1 Mon Sep 17 00:00:00 2001 From: DanGould Date: Thu, 2 Feb 2023 12:54:30 -0500 Subject: [PATCH] Carry ConsensusEncoding(encode::Error) When psbt::Error was Eq, it could not have associated dyn error types. --- bitcoin/src/psbt/error.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bitcoin/src/psbt/error.rs b/bitcoin/src/psbt/error.rs index cae556ac..47bd4df7 100644 --- a/bitcoin/src/psbt/error.rs +++ b/bitcoin/src/psbt/error.rs @@ -74,7 +74,7 @@ pub enum Error { /// global extended public key has inconsistent key sources CombineInconsistentKeySources(Box), /// Serialization error in bitcoin consensus-encoded structures - ConsensusEncoding, + ConsensusEncoding(encode::Error), /// Negative fee NegativeFee, /// 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 ) }, 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::FeeOverflow => f.write_str("integer overflow in fee calculation"), Error::InvalidPublicKey(ref e) => write_err!(f, "invalid public key"; e), @@ -156,6 +156,7 @@ impl std::error::Error for Error { match self { HashParse(e) => Some(e), + ConsensusEncoding(e) => Some(e), Io(e) => Some(e), | InvalidMagic | MissingUtxo @@ -172,7 +173,6 @@ impl std::error::Error for Error { | NonStandardSighashType(_) | InvalidPreimageHashPair{ .. } | CombineInconsistentKeySources(_) - | ConsensusEncoding | NegativeFee | FeeOverflow | InvalidPublicKey(_) @@ -198,8 +198,8 @@ impl From for Error { } impl From for Error { - fn from(_: encode::Error) -> Self { - Error::ConsensusEncoding + fn from(e: encode::Error) -> Self { + Error::ConsensusEncoding(e) } }