From e356ff661182eb15b9d3d18b2c200f20e3bda76e Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 17 Jan 2024 13:39:02 +1100 Subject: [PATCH] Remove the now unused sighash::Error type --- bitcoin/src/crypto/sighash.rs | 95 ----------------------------------- 1 file changed, 95 deletions(-) diff --git a/bitcoin/src/crypto/sighash.rs b/bitcoin/src/crypto/sighash.rs index c50f13dc..de1767a4 100644 --- a/bitcoin/src/crypto/sighash.rs +++ b/bitcoin/src/crypto/sighash.rs @@ -198,101 +198,6 @@ impl str::FromStr for TapSighashType { } } -/// Possible errors in computing the signature message. -#[derive(Debug, Clone, PartialEq, Eq)] -#[non_exhaustive] -pub enum Error { - /// Could happen only by using `*_encode_signing_*` methods with custom writers, engines writers - /// like the ones used in methods `*_signature_hash` do not error. - Io(io::ErrorKind), - - /// Requested index is greater or equal than the number of inputs in the transaction. - IndexOutOfInputsBounds { - /// Requested index. - index: usize, - /// Number of transaction inputs. - inputs_size: usize, - }, - - /// Using `SIGHASH_SINGLE` without a "corresponding output" (an output with the same index as - /// the input being verified) is a validation failure. - SingleWithoutCorrespondingOutput { - /// Requested index. - index: usize, - /// Number of transaction outputs. - outputs_size: usize, - }, - - /// There are mismatches in the number of prevouts provided compared to the number of inputs in - /// the transaction. - PrevoutsSize(PrevoutsSizeError), - - /// Requested a prevout index which is greater than the number of prevouts provided or a - /// [`Prevouts::One`] with different index. - PrevoutsIndex(PrevoutsIndexError), - - /// A single prevout has been provided but all prevouts are needed unless using - /// `SIGHASH_ANYONECANPAY`. - PrevoutsKind(PrevoutsKindError), - - /// Invalid Sighash type. - InvalidSighashType(u32), - - /// Script is not a witness program for a p2wpkh output. - NotP2wpkhScript, -} - -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - use Error::*; - - match *self { - Io(error_kind) => write!(f, "writer errored: {:?}", error_kind), - IndexOutOfInputsBounds { index, inputs_size } => write!(f, "requested index ({}) is greater or equal than the number of transaction inputs ({})", index, inputs_size), - SingleWithoutCorrespondingOutput { index, outputs_size } => write!(f, "SIGHASH_SINGLE for input ({}) haven't a corresponding output (#outputs:{})", index, outputs_size), - PrevoutsSize(ref e) => write_err!(f, "prevouts size"; e), - PrevoutsIndex(ref e) => write_err!(f, "prevouts index"; e), - PrevoutsKind(ref e) => write_err!(f, "prevouts kind"; e), - InvalidSighashType(hash_ty) => write!(f, "Invalid taproot signature hash type : {} ", hash_ty), - NotP2wpkhScript => write!(f, "script is not a script pubkey for a p2wpkh output"), - } - } -} - -#[cfg(feature = "std")] -impl std::error::Error for Error { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { - use Error::*; - - match *self { - PrevoutsSize(ref e) => Some(e), - PrevoutsIndex(ref e) => Some(e), - PrevoutsKind(ref e) => Some(e), - Io(_) - | IndexOutOfInputsBounds { .. } - | SingleWithoutCorrespondingOutput { .. } - | InvalidSighashType(_) - | NotP2wpkhScript => None, - } - } -} - -impl From for Error { - fn from(e: io::Error) -> Self { Self::Io(e.kind()) } -} - -impl From for Error { - fn from(e: PrevoutsSizeError) -> Self { Self::PrevoutsSize(e) } -} - -impl From for Error { - fn from(e: PrevoutsKindError) -> Self { Self::PrevoutsKind(e) } -} - -impl From for Error { - fn from(e: PrevoutsIndexError) -> Self { Self::PrevoutsIndex(e) } -} - impl<'u, T> Prevouts<'u, T> where T: Borrow,