diff --git a/src/util/sighash.rs b/src/util/sighash.rs index ed4bfb7d..09bdaa65 100644 --- a/src/util/sighash.rs +++ b/src/util/sighash.rs @@ -32,6 +32,7 @@ use {Script, Transaction, TxOut}; use prelude::*; /// Efficiently calculates signature hash message for legacy, segwit and taproot inputs. +#[derive(Debug)] pub struct SigHashCache> { /// Access to transaction required for various introspection, moreover type /// `T: Deref` allows to accept borrow and mutable borrow, the @@ -49,7 +50,8 @@ pub struct SigHashCache> { } /// Values cached common between segwit and taproot inputs -pub struct CommonCache { +#[derive(Debug)] +struct CommonCache { prevouts: sha256::Hash, sequences: sha256::Hash, @@ -59,20 +61,23 @@ pub struct CommonCache { } /// Values cached for segwit inputs, it's equal to [CommonCache] plus another round of `sha256` -pub struct SegwitCache { +#[derive(Debug)] +struct SegwitCache { prevouts: sha256d::Hash, sequences: sha256d::Hash, outputs: sha256d::Hash, } /// Values cached for taproot inputs -pub struct TaprootCache { +#[derive(Debug)] +struct TaprootCache { amounts: sha256::Hash, script_pubkeys: sha256::Hash, } /// Contains outputs of previous transactions. /// In the case [SigHashType] variant is `ANYONECANPAY`, [Prevouts::One] may be provided +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] pub enum Prevouts<'u> { /// `One` variant allows to provide the single Prevout needed. It's useful for example /// when modifier `ANYONECANPAY` is provided, only prevout of the current input is needed. @@ -86,6 +91,7 @@ pub enum Prevouts<'u> { const LEAF_VERSION_TAPSCRIPT: u8 = 0xc0; /// Information related to the script path spending +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] pub struct ScriptPath<'s> { script: &'s Script, code_separator_pos: u32, @@ -94,7 +100,7 @@ pub struct ScriptPath<'s> { /// Hashtype of an input's signature, encoded in the last byte of the signature /// Fixed values so they can be casted as integer types for encoding -#[derive(PartialEq, Eq, Debug, Copy, Clone)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] pub enum SigHashType { /// 0x0: Used when not explicitly specified, defaulting to [SigHashType::All] Default = 0x00, @@ -119,7 +125,7 @@ pub enum SigHashType { } /// Possible errors in computing the signature message -#[derive(Debug, Eq, PartialEq)] +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)] pub enum Error { /// Should never happen since we are always encoding, thus we are avoiding wrap the IO error IoError,