Move impl_asref_push_bytes to internal_macros
We are emptying the `hash_types` module. `impl_asref_push_bytes!` is an internal macro, as such it can live in the `internal_macros` module. While we are at it import the macro and call it without any qualifying path, this is typical for our usage of other internals/internal_macros usage.
This commit is contained in:
parent
2b4b66dee3
commit
61351c917f
|
@ -72,6 +72,7 @@ use serde;
|
||||||
use crate::blockdata::opcodes::all::*;
|
use crate::blockdata::opcodes::all::*;
|
||||||
use crate::blockdata::opcodes::{self, Opcode};
|
use crate::blockdata::opcodes::{self, Opcode};
|
||||||
use crate::consensus::{encode, Decodable, Encodable};
|
use crate::consensus::{encode, Decodable, Encodable};
|
||||||
|
use crate::internal_macros::impl_asref_push_bytes;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{io, OutPoint};
|
use crate::{io, OutPoint};
|
||||||
|
|
||||||
|
@ -91,7 +92,7 @@ hashes::hash_newtype! {
|
||||||
/// SegWit version of a Bitcoin Script bytecode hash.
|
/// SegWit version of a Bitcoin Script bytecode hash.
|
||||||
pub struct WScriptHash(sha256::Hash);
|
pub struct WScriptHash(sha256::Hash);
|
||||||
}
|
}
|
||||||
crate::hash_types::impl_asref_push_bytes!(ScriptHash, WScriptHash);
|
impl_asref_push_bytes!(ScriptHash, WScriptHash);
|
||||||
|
|
||||||
impl From<ScriptBuf> for ScriptHash {
|
impl From<ScriptBuf> for ScriptHash {
|
||||||
fn from(script: ScriptBuf) -> ScriptHash { script.script_hash() }
|
fn from(script: ScriptBuf) -> ScriptHash { script.script_hash() }
|
||||||
|
|
|
@ -14,6 +14,7 @@ use hex::FromHex;
|
||||||
use internals::write_err;
|
use internals::write_err;
|
||||||
|
|
||||||
use crate::crypto::ecdsa;
|
use crate::crypto::ecdsa;
|
||||||
|
use crate::internal_macros::impl_asref_push_bytes;
|
||||||
use crate::network::Network;
|
use crate::network::Network;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::taproot::{TapNodeHash, TapTweakHash};
|
use crate::taproot::{TapNodeHash, TapTweakHash};
|
||||||
|
@ -252,7 +253,7 @@ hashes::hash_newtype! {
|
||||||
/// SegWit version of a public key hash.
|
/// SegWit version of a public key hash.
|
||||||
pub struct WPubkeyHash(hash160::Hash);
|
pub struct WPubkeyHash(hash160::Hash);
|
||||||
}
|
}
|
||||||
crate::hash_types::impl_asref_push_bytes!(PubkeyHash, WPubkeyHash);
|
impl_asref_push_bytes!(PubkeyHash, WPubkeyHash);
|
||||||
|
|
||||||
impl From<PublicKey> for PubkeyHash {
|
impl From<PublicKey> for PubkeyHash {
|
||||||
fn from(key: PublicKey) -> PubkeyHash { key.pubkey_hash() }
|
fn from(key: PublicKey) -> PubkeyHash { key.pubkey_hash() }
|
||||||
|
|
|
@ -8,28 +8,6 @@
|
||||||
//! hash).
|
//! hash).
|
||||||
//!
|
//!
|
||||||
|
|
||||||
#[rustfmt::skip]
|
|
||||||
macro_rules! impl_asref_push_bytes {
|
|
||||||
($($hashtype:ident),*) => {
|
|
||||||
$(
|
|
||||||
impl AsRef<$crate::blockdata::script::PushBytes> for $hashtype {
|
|
||||||
fn as_ref(&self) -> &$crate::blockdata::script::PushBytes {
|
|
||||||
use $crate::hashes::Hash;
|
|
||||||
self.as_byte_array().into()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<$hashtype> for $crate::blockdata::script::PushBytesBuf {
|
|
||||||
fn from(hash: $hashtype) -> Self {
|
|
||||||
use $crate::hashes::Hash;
|
|
||||||
hash.as_byte_array().into()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)*
|
|
||||||
};
|
|
||||||
}
|
|
||||||
pub(crate) use impl_asref_push_bytes;
|
|
||||||
|
|
||||||
#[deprecated(since = "0.0.0-NEXT-RELEASE", note = "use crate::T instead")]
|
#[deprecated(since = "0.0.0-NEXT-RELEASE", note = "use crate::T instead")]
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
BlockHash, FilterHash, FilterHeader, TxMerkleNode, Txid, WitnessCommitment, WitnessMerkleNode,
|
BlockHash, FilterHash, FilterHeader, TxMerkleNode, Txid, WitnessCommitment, WitnessMerkleNode,
|
||||||
|
|
|
@ -210,3 +210,25 @@ macro_rules! impl_hashencode {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
pub(crate) use impl_hashencode;
|
pub(crate) use impl_hashencode;
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
|
macro_rules! impl_asref_push_bytes {
|
||||||
|
($($hashtype:ident),*) => {
|
||||||
|
$(
|
||||||
|
impl AsRef<$crate::blockdata::script::PushBytes> for $hashtype {
|
||||||
|
fn as_ref(&self) -> &$crate::blockdata::script::PushBytes {
|
||||||
|
use $crate::hashes::Hash;
|
||||||
|
self.as_byte_array().into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<$hashtype> for $crate::blockdata::script::PushBytesBuf {
|
||||||
|
fn from(hash: $hashtype) -> Self {
|
||||||
|
use $crate::hashes::Hash;
|
||||||
|
hash.as_byte_array().into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)*
|
||||||
|
};
|
||||||
|
}
|
||||||
|
pub(crate) use impl_asref_push_bytes;
|
||||||
|
|
Loading…
Reference in New Issue