Move transaction hash types
We would like all the various hash types to be defined where they rightly live instead of in the `hash_types` module. Move transaction hash types to the `transaction` module.
This commit is contained in:
parent
61c02ff202
commit
3107f80aac
|
@ -14,9 +14,9 @@ use hashes::{sha256d, Hash, HashEngine};
|
||||||
|
|
||||||
use super::Weight;
|
use super::Weight;
|
||||||
use crate::blockdata::script;
|
use crate::blockdata::script;
|
||||||
use crate::blockdata::transaction::Transaction;
|
use crate::blockdata::transaction::{Transaction, Txid, Wtxid};
|
||||||
use crate::consensus::{encode, Decodable, Encodable};
|
use crate::consensus::{encode, Decodable, Encodable};
|
||||||
use crate::hash_types::{impl_hashencode, Txid, Wtxid};
|
use crate::hash_types::impl_hashencode;
|
||||||
use crate::internal_macros::impl_consensus_encoding;
|
use crate::internal_macros::impl_consensus_encoding;
|
||||||
use crate::pow::{CompactTarget, Target, Work};
|
use crate::pow::{CompactTarget, Target, Work};
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
|
@ -23,7 +23,7 @@ use crate::blockdata::locktime::relative;
|
||||||
use crate::blockdata::script::{Script, ScriptBuf};
|
use crate::blockdata::script::{Script, ScriptBuf};
|
||||||
use crate::blockdata::witness::Witness;
|
use crate::blockdata::witness::Witness;
|
||||||
use crate::consensus::{encode, Decodable, Encodable};
|
use crate::consensus::{encode, Decodable, Encodable};
|
||||||
use crate::hash_types::{Txid, Wtxid};
|
use crate::hash_types::impl_hashencode;
|
||||||
use crate::internal_macros::impl_consensus_encoding;
|
use crate::internal_macros::impl_consensus_encoding;
|
||||||
use crate::parse::impl_parse_str_from_int_infallible;
|
use crate::parse::impl_parse_str_from_int_infallible;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
@ -38,6 +38,21 @@ use crate::{Amount, VarInt};
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use crate::consensus::validation::TxVerifyError;
|
pub use crate::consensus::validation::TxVerifyError;
|
||||||
|
|
||||||
|
hashes::hash_newtype! {
|
||||||
|
/// A bitcoin transaction hash/transaction ID.
|
||||||
|
///
|
||||||
|
/// For compatibility with the existing Bitcoin infrastructure and historical and current
|
||||||
|
/// versions of the Bitcoin Core software itself, this and other [`sha256d::Hash`] types, are
|
||||||
|
/// serialized in reverse byte order when converted to a hex string via [`std::fmt::Display`]
|
||||||
|
/// trait operations. See [`hashes::Hash::DISPLAY_BACKWARD`] for more details.
|
||||||
|
pub struct Txid(sha256d::Hash);
|
||||||
|
|
||||||
|
/// A bitcoin witness transaction ID.
|
||||||
|
pub struct Wtxid(sha256d::Hash);
|
||||||
|
}
|
||||||
|
impl_hashencode!(Txid);
|
||||||
|
impl_hashencode!(Wtxid);
|
||||||
|
|
||||||
/// The marker MUST be a 1-byte zero value: 0x00. (BIP-141)
|
/// The marker MUST be a 1-byte zero value: 0x00. (BIP-141)
|
||||||
const SEGWIT_MARKER: u8 = 0x00;
|
const SEGWIT_MARKER: u8 = 0x00;
|
||||||
/// The flag MUST be a 1-byte non-zero value. Currently, 0x01 MUST be used. (BIP-141)
|
/// The flag MUST be a 1-byte non-zero value. Currently, 0x01 MUST be used. (BIP-141)
|
||||||
|
|
|
@ -59,30 +59,15 @@ mod newtypes {
|
||||||
use hashes::{sha256d, hash_newtype};
|
use hashes::{sha256d, hash_newtype};
|
||||||
|
|
||||||
hash_newtype! {
|
hash_newtype! {
|
||||||
/// A bitcoin transaction hash/transaction ID.
|
|
||||||
///
|
|
||||||
/// For compatibility with the existing Bitcoin infrastructure and historical
|
|
||||||
/// and current versions of the Bitcoin Core software itself, this and
|
|
||||||
/// other [`sha256d::Hash`] types, are serialized in reverse
|
|
||||||
/// byte order when converted to a hex string via [`std::fmt::Display`] trait operations.
|
|
||||||
/// See [`hashes::Hash::DISPLAY_BACKWARD`] for more details.
|
|
||||||
pub struct Txid(sha256d::Hash);
|
|
||||||
|
|
||||||
/// A bitcoin witness transaction ID.
|
|
||||||
pub struct Wtxid(sha256d::Hash);
|
|
||||||
|
|
||||||
/// Filter hash, as defined in BIP-157
|
/// Filter hash, as defined in BIP-157
|
||||||
pub struct FilterHash(sha256d::Hash);
|
pub struct FilterHash(sha256d::Hash);
|
||||||
/// Filter header, as defined in BIP-157
|
/// Filter header, as defined in BIP-157
|
||||||
pub struct FilterHeader(sha256d::Hash);
|
pub struct FilterHeader(sha256d::Hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_hashencode!(Txid);
|
|
||||||
impl_hashencode!(Wtxid);
|
|
||||||
|
|
||||||
impl_hashencode!(FilterHash);
|
impl_hashencode!(FilterHash);
|
||||||
impl_hashencode!(FilterHeader);
|
impl_hashencode!(FilterHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[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::{BlockHash, TxMerkleNode, WitnessCommitment, WitnessMerkleNode};
|
pub use crate::{BlockHash, TxMerkleNode, Txid, WitnessCommitment, WitnessMerkleNode, Wtxid};
|
||||||
|
|
|
@ -130,14 +130,14 @@ pub use crate::{
|
||||||
blockdata::script::witness_program::{self, WitnessProgram},
|
blockdata::script::witness_program::{self, WitnessProgram},
|
||||||
blockdata::script::witness_version::{self, WitnessVersion},
|
blockdata::script::witness_version::{self, WitnessVersion},
|
||||||
blockdata::script::{self, Script, ScriptBuf, ScriptHash, WScriptHash},
|
blockdata::script::{self, Script, ScriptBuf, ScriptHash, WScriptHash},
|
||||||
blockdata::transaction::{self, OutPoint, Sequence, Transaction, TxIn, TxOut},
|
blockdata::transaction::{self, OutPoint, Sequence, Transaction, TxIn, TxOut, Txid, Wtxid},
|
||||||
blockdata::weight::Weight,
|
blockdata::weight::Weight,
|
||||||
blockdata::witness::{self, Witness},
|
blockdata::witness::{self, Witness},
|
||||||
consensus::encode::VarInt,
|
consensus::encode::VarInt,
|
||||||
crypto::ecdsa,
|
crypto::ecdsa,
|
||||||
crypto::key::{self, PrivateKey, PubkeyHash, PublicKey, WPubkeyHash, XOnlyPublicKey},
|
crypto::key::{self, PrivateKey, PubkeyHash, PublicKey, WPubkeyHash, XOnlyPublicKey},
|
||||||
crypto::sighash::{self, LegacySighash, SegwitV0Sighash, TapSighash, TapSighashTag},
|
crypto::sighash::{self, LegacySighash, SegwitV0Sighash, TapSighash, TapSighashTag},
|
||||||
hash_types::{FilterHash, FilterHeader, Txid, Wtxid},
|
hash_types::{FilterHash, FilterHeader},
|
||||||
merkle_tree::MerkleBlock,
|
merkle_tree::MerkleBlock,
|
||||||
network::Network,
|
network::Network,
|
||||||
pow::{CompactTarget, Target, Work},
|
pow::{CompactTarget, Target, Work},
|
||||||
|
|
|
@ -44,10 +44,9 @@ use hashes::Hash;
|
||||||
|
|
||||||
use self::MerkleBlockError::*;
|
use self::MerkleBlockError::*;
|
||||||
use crate::blockdata::block::{self, Block, TxMerkleNode};
|
use crate::blockdata::block::{self, Block, TxMerkleNode};
|
||||||
use crate::blockdata::transaction::Transaction;
|
use crate::blockdata::transaction::{Transaction, Txid};
|
||||||
use crate::blockdata::weight::Weight;
|
use crate::blockdata::weight::Weight;
|
||||||
use crate::consensus::encode::{self, Decodable, Encodable};
|
use crate::consensus::encode::{self, Decodable, Encodable};
|
||||||
use crate::hash_types::Txid;
|
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
/// Data structure that represents a block header paired to a partial merkle tree.
|
/// Data structure that represents a block header paired to a partial merkle tree.
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
use hashes::{sha256d, Hash as _};
|
use hashes::{sha256d, Hash as _};
|
||||||
|
|
||||||
use crate::blockdata::block::BlockHash;
|
use crate::blockdata::block::BlockHash;
|
||||||
|
use crate::blockdata::transaction::{Txid, Wtxid};
|
||||||
use crate::consensus::encode::{self, Decodable, Encodable};
|
use crate::consensus::encode::{self, Decodable, Encodable};
|
||||||
use crate::hash_types::{Txid, Wtxid};
|
|
||||||
use crate::internal_macros::impl_consensus_encoding;
|
use crate::internal_macros::impl_consensus_encoding;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{io, p2p};
|
use crate::{io, p2p};
|
||||||
|
|
Loading…
Reference in New Issue