From 130e27349edb79a535ea731b4f54f2efd221abe7 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 29 Mar 2022 08:54:02 +1100 Subject: [PATCH] Rename SigHashTypeParseError -> SighashTypeParseError Our usage of `SigHash` implies that 'sighash' is _two_ words; 'sighash' is a well known word in the Bitcoin ecosystem it should appear in identifiers as `Sighash`. Rename `SigHashTypeParseError` to `SighashTypeParseError`. --- src/blockdata/transaction.rs | 10 +++++----- src/util/psbt/map/input.rs | 8 ++++---- src/util/sighash.rs | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/blockdata/transaction.rs b/src/blockdata/transaction.rs index 984e1ac8..ee5bc4f9 100644 --- a/src/blockdata/transaction.rs +++ b/src/blockdata/transaction.rs @@ -778,7 +778,7 @@ impl fmt::Display for EcdsaSighashType { } impl str::FromStr for EcdsaSighashType { - type Err = SigHashTypeParseError; + type Err = SighashTypeParseError; fn from_str(s: &str) -> Result { match s { @@ -788,7 +788,7 @@ impl str::FromStr for EcdsaSighashType { "SIGHASH_ALL|SIGHASH_ANYONECANPAY" => Ok(EcdsaSighashType::AllPlusAnyoneCanPay), "SIGHASH_NONE|SIGHASH_ANYONECANPAY" => Ok(EcdsaSighashType::NonePlusAnyoneCanPay), "SIGHASH_SINGLE|SIGHASH_ANYONECANPAY" => Ok(EcdsaSighashType::SinglePlusAnyoneCanPay), - _ => Err(SigHashTypeParseError { unrecognized: s.to_owned() }), + _ => Err(SighashTypeParseError { unrecognized: s.to_owned() }), } } } @@ -875,12 +875,12 @@ impl EcdsaSighashType { /// /// This is currently returned for unrecognized sighash strings. #[derive(Debug, Clone)] -pub struct SigHashTypeParseError { +pub struct SighashTypeParseError { /// The unrecognized string we attempted to parse. pub unrecognized: String, } -impl fmt::Display for SigHashTypeParseError { +impl fmt::Display for SighashTypeParseError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Unrecognized SIGHASH string '{}'", self.unrecognized) } @@ -888,7 +888,7 @@ impl fmt::Display for SigHashTypeParseError { #[cfg_attr(docsrs, doc(cfg(feature = "std")))] #[cfg(feature = "std")] -impl ::std::error::Error for SigHashTypeParseError {} +impl ::std::error::Error for SighashTypeParseError {} #[cfg(test)] mod tests { diff --git a/src/util/psbt/map/input.rs b/src/util/psbt/map/input.rs index 6362748d..f575a5c8 100644 --- a/src/util/psbt/map/input.rs +++ b/src/util/psbt/map/input.rs @@ -20,7 +20,7 @@ use core::str::FromStr; use secp256k1; use blockdata::script::Script; use blockdata::witness::Witness; -use blockdata::transaction::{Transaction, TxOut, NonStandardSigHashType, SigHashTypeParseError}; +use blockdata::transaction::{Transaction, TxOut, NonStandardSigHashType, SighashTypeParseError}; use consensus::encode; use hashes::{self, hash160, ripemd160, sha256, sha256d}; use secp256k1::XOnlyPublicKey; @@ -167,7 +167,7 @@ impl fmt::Display for PsbtSigHashType { } impl FromStr for PsbtSigHashType { - type Err = SigHashTypeParseError; + type Err = SighashTypeParseError; #[inline] fn from_str(s: &str) -> Result { @@ -177,7 +177,7 @@ impl FromStr for PsbtSigHashType { // inputs. We also do not support SIGHASH_RESERVED in verbatim form // ("0xFF" string should be used instead). match SchnorrSighashType::from_str(s) { - Ok(SchnorrSighashType::Reserved) => return Err(SigHashTypeParseError{ unrecognized: s.to_owned() }), + Ok(SchnorrSighashType::Reserved) => return Err(SighashTypeParseError{ unrecognized: s.to_owned() }), Ok(ty) => return Ok(ty.into()), Err(_) => {} } @@ -188,7 +188,7 @@ impl FromStr for PsbtSigHashType { return Ok(PsbtSigHashType { inner }); } - Err(SigHashTypeParseError{ unrecognized: s.to_owned() }) + Err(SighashTypeParseError{ unrecognized: s.to_owned() }) } } impl From for PsbtSigHashType { diff --git a/src/util/sighash.rs b/src/util/sighash.rs index 2eb62309..6babb5a0 100644 --- a/src/util/sighash.rs +++ b/src/util/sighash.rs @@ -22,7 +22,7 @@ use prelude::*; -pub use blockdata::transaction::{EcdsaSighashType, SigHashTypeParseError}; +pub use blockdata::transaction::{EcdsaSighashType, SighashTypeParseError}; use blockdata::witness::Witness; use consensus::{encode, Encodable}; use core::{str, fmt}; @@ -148,7 +148,7 @@ impl fmt::Display for SchnorrSighashType { } impl str::FromStr for SchnorrSighashType { - type Err = SigHashTypeParseError; + type Err = SighashTypeParseError; fn from_str(s: &str) -> Result { match s { @@ -160,7 +160,7 @@ impl str::FromStr for SchnorrSighashType { "SIGHASH_NONE|SIGHASH_ANYONECANPAY" => Ok(SchnorrSighashType::NonePlusAnyoneCanPay), "SIGHASH_SINGLE|SIGHASH_ANYONECANPAY" => Ok(SchnorrSighashType::SinglePlusAnyoneCanPay), "SIGHASH_RESERVED" => Ok(SchnorrSighashType::Reserved), - _ => Err(SigHashTypeParseError{ unrecognized: s.to_owned() }), + _ => Err(SighashTypeParseError{ unrecognized: s.to_owned() }), } } }