Remove the now unused sighash::Error type
This commit is contained in:
parent
c17324c574
commit
e356ff6611
|
@ -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<io::Error> for Error {
|
|
||||||
fn from(e: io::Error) -> Self { Self::Io(e.kind()) }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<PrevoutsSizeError> for Error {
|
|
||||||
fn from(e: PrevoutsSizeError) -> Self { Self::PrevoutsSize(e) }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<PrevoutsKindError> for Error {
|
|
||||||
fn from(e: PrevoutsKindError) -> Self { Self::PrevoutsKind(e) }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<PrevoutsIndexError> for Error {
|
|
||||||
fn from(e: PrevoutsIndexError) -> Self { Self::PrevoutsIndex(e) }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'u, T> Prevouts<'u, T>
|
impl<'u, T> Prevouts<'u, T>
|
||||||
where
|
where
|
||||||
T: Borrow<TxOut>,
|
T: Borrow<TxOut>,
|
||||||
|
|
Loading…
Reference in New Issue