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`.
This commit is contained in:
parent
6caba2ed24
commit
130e27349e
|
@ -778,7 +778,7 @@ impl fmt::Display for EcdsaSighashType {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl str::FromStr for EcdsaSighashType {
|
impl str::FromStr for EcdsaSighashType {
|
||||||
type Err = SigHashTypeParseError;
|
type Err = SighashTypeParseError;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
match s {
|
match s {
|
||||||
|
@ -788,7 +788,7 @@ impl str::FromStr for EcdsaSighashType {
|
||||||
"SIGHASH_ALL|SIGHASH_ANYONECANPAY" => Ok(EcdsaSighashType::AllPlusAnyoneCanPay),
|
"SIGHASH_ALL|SIGHASH_ANYONECANPAY" => Ok(EcdsaSighashType::AllPlusAnyoneCanPay),
|
||||||
"SIGHASH_NONE|SIGHASH_ANYONECANPAY" => Ok(EcdsaSighashType::NonePlusAnyoneCanPay),
|
"SIGHASH_NONE|SIGHASH_ANYONECANPAY" => Ok(EcdsaSighashType::NonePlusAnyoneCanPay),
|
||||||
"SIGHASH_SINGLE|SIGHASH_ANYONECANPAY" => Ok(EcdsaSighashType::SinglePlusAnyoneCanPay),
|
"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.
|
/// This is currently returned for unrecognized sighash strings.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct SigHashTypeParseError {
|
pub struct SighashTypeParseError {
|
||||||
/// The unrecognized string we attempted to parse.
|
/// The unrecognized string we attempted to parse.
|
||||||
pub unrecognized: String,
|
pub unrecognized: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for SigHashTypeParseError {
|
impl fmt::Display for SighashTypeParseError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
write!(f, "Unrecognized SIGHASH string '{}'", self.unrecognized)
|
write!(f, "Unrecognized SIGHASH string '{}'", self.unrecognized)
|
||||||
}
|
}
|
||||||
|
@ -888,7 +888,7 @@ impl fmt::Display for SigHashTypeParseError {
|
||||||
|
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "std")))]
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
impl ::std::error::Error for SigHashTypeParseError {}
|
impl ::std::error::Error for SighashTypeParseError {}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
|
|
@ -20,7 +20,7 @@ use core::str::FromStr;
|
||||||
use secp256k1;
|
use secp256k1;
|
||||||
use blockdata::script::Script;
|
use blockdata::script::Script;
|
||||||
use blockdata::witness::Witness;
|
use blockdata::witness::Witness;
|
||||||
use blockdata::transaction::{Transaction, TxOut, NonStandardSigHashType, SigHashTypeParseError};
|
use blockdata::transaction::{Transaction, TxOut, NonStandardSigHashType, SighashTypeParseError};
|
||||||
use consensus::encode;
|
use consensus::encode;
|
||||||
use hashes::{self, hash160, ripemd160, sha256, sha256d};
|
use hashes::{self, hash160, ripemd160, sha256, sha256d};
|
||||||
use secp256k1::XOnlyPublicKey;
|
use secp256k1::XOnlyPublicKey;
|
||||||
|
@ -167,7 +167,7 @@ impl fmt::Display for PsbtSigHashType {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for PsbtSigHashType {
|
impl FromStr for PsbtSigHashType {
|
||||||
type Err = SigHashTypeParseError;
|
type Err = SighashTypeParseError;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
|
@ -177,7 +177,7 @@ impl FromStr for PsbtSigHashType {
|
||||||
// inputs. We also do not support SIGHASH_RESERVED in verbatim form
|
// inputs. We also do not support SIGHASH_RESERVED in verbatim form
|
||||||
// ("0xFF" string should be used instead).
|
// ("0xFF" string should be used instead).
|
||||||
match SchnorrSighashType::from_str(s) {
|
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()),
|
Ok(ty) => return Ok(ty.into()),
|
||||||
Err(_) => {}
|
Err(_) => {}
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ impl FromStr for PsbtSigHashType {
|
||||||
return Ok(PsbtSigHashType { inner });
|
return Ok(PsbtSigHashType { inner });
|
||||||
}
|
}
|
||||||
|
|
||||||
Err(SigHashTypeParseError{ unrecognized: s.to_owned() })
|
Err(SighashTypeParseError{ unrecognized: s.to_owned() })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl From<EcdsaSighashType> for PsbtSigHashType {
|
impl From<EcdsaSighashType> for PsbtSigHashType {
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
use prelude::*;
|
use prelude::*;
|
||||||
|
|
||||||
pub use blockdata::transaction::{EcdsaSighashType, SigHashTypeParseError};
|
pub use blockdata::transaction::{EcdsaSighashType, SighashTypeParseError};
|
||||||
use blockdata::witness::Witness;
|
use blockdata::witness::Witness;
|
||||||
use consensus::{encode, Encodable};
|
use consensus::{encode, Encodable};
|
||||||
use core::{str, fmt};
|
use core::{str, fmt};
|
||||||
|
@ -148,7 +148,7 @@ impl fmt::Display for SchnorrSighashType {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl str::FromStr for SchnorrSighashType {
|
impl str::FromStr for SchnorrSighashType {
|
||||||
type Err = SigHashTypeParseError;
|
type Err = SighashTypeParseError;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
match s {
|
match s {
|
||||||
|
@ -160,7 +160,7 @@ impl str::FromStr for SchnorrSighashType {
|
||||||
"SIGHASH_NONE|SIGHASH_ANYONECANPAY" => Ok(SchnorrSighashType::NonePlusAnyoneCanPay),
|
"SIGHASH_NONE|SIGHASH_ANYONECANPAY" => Ok(SchnorrSighashType::NonePlusAnyoneCanPay),
|
||||||
"SIGHASH_SINGLE|SIGHASH_ANYONECANPAY" => Ok(SchnorrSighashType::SinglePlusAnyoneCanPay),
|
"SIGHASH_SINGLE|SIGHASH_ANYONECANPAY" => Ok(SchnorrSighashType::SinglePlusAnyoneCanPay),
|
||||||
"SIGHASH_RESERVED" => Ok(SchnorrSighashType::Reserved),
|
"SIGHASH_RESERVED" => Ok(SchnorrSighashType::Reserved),
|
||||||
_ => Err(SigHashTypeParseError{ unrecognized: s.to_owned() }),
|
_ => Err(SighashTypeParseError{ unrecognized: s.to_owned() }),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue