Merge rust-bitcoin/rust-bitcoin#1065: Upgrade `bitcoin_hashes` dependency
1e46eeaa88
Upgrade to bitcoin_hashes v0.11.0 (Tobin C. Harding) Pull request description: We just released a new version of `bitcoin_hashes`, upgrade the dependency to v0.11.0 ACKs for top commit: apoelstra: ACK1e46eeaa88
Kixunil: ACK1e46eeaa88
Tree-SHA512: 32173349c280c255681ebf15a1aa98a28b7016bb813ca907ac55a9797d9d17e1da344e2d8e74c02c2c80d2e6873a03f522c2d55b289b65d7ac55f402b19d689b
This commit is contained in:
commit
ed00c2aab9
|
@ -35,7 +35,7 @@ rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bech32 = { version = "0.8.1", default-features = false }
|
bech32 = { version = "0.8.1", default-features = false }
|
||||||
bitcoin_hashes = { version = "0.10.0", default-features = false }
|
bitcoin_hashes = { version = "0.11.0", default-features = false }
|
||||||
secp256k1 = { version = "0.23.0", default-features = false }
|
secp256k1 = { version = "0.23.0", default-features = false }
|
||||||
core2 = { version = "0.3.0", optional = true, default-features = false }
|
core2 = { version = "0.3.0", optional = true, default-features = false }
|
||||||
|
|
||||||
|
|
|
@ -254,7 +254,7 @@ impl Block {
|
||||||
let hashes = self.txdata.iter().enumerate().map(|(i, t)| {
|
let hashes = self.txdata.iter().enumerate().map(|(i, t)| {
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
// Replace the first hash with zeroes.
|
// Replace the first hash with zeroes.
|
||||||
Wtxid::default().as_hash()
|
Wtxid::all_zeros().as_hash()
|
||||||
} else {
|
} else {
|
||||||
t.wtxid().as_hash()
|
t.wtxid().as_hash()
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ use crate::prelude::*;
|
||||||
use core::default::Default;
|
use core::default::Default;
|
||||||
|
|
||||||
use crate::hashes::hex::{self, HexIterator};
|
use crate::hashes::hex::{self, HexIterator};
|
||||||
use crate::hashes::sha256d;
|
use crate::hashes::{Hash, sha256d};
|
||||||
use crate::blockdata::opcodes;
|
use crate::blockdata::opcodes;
|
||||||
use crate::blockdata::script;
|
use crate::blockdata::script;
|
||||||
use crate::blockdata::transaction::{OutPoint, Transaction, TxOut, TxIn};
|
use crate::blockdata::transaction::{OutPoint, Transaction, TxOut, TxIn};
|
||||||
|
@ -114,7 +114,7 @@ pub fn genesis_block(network: Network) -> Block {
|
||||||
Block {
|
Block {
|
||||||
header: BlockHeader {
|
header: BlockHeader {
|
||||||
version: 1,
|
version: 1,
|
||||||
prev_blockhash: Default::default(),
|
prev_blockhash: Hash::all_zeros(),
|
||||||
merkle_root,
|
merkle_root,
|
||||||
time: 1231006505,
|
time: 1231006505,
|
||||||
bits: 0x1d00ffff,
|
bits: 0x1d00ffff,
|
||||||
|
@ -127,7 +127,7 @@ pub fn genesis_block(network: Network) -> Block {
|
||||||
Block {
|
Block {
|
||||||
header: BlockHeader {
|
header: BlockHeader {
|
||||||
version: 1,
|
version: 1,
|
||||||
prev_blockhash: Default::default(),
|
prev_blockhash: Hash::all_zeros(),
|
||||||
merkle_root,
|
merkle_root,
|
||||||
time: 1296688602,
|
time: 1296688602,
|
||||||
bits: 0x1d00ffff,
|
bits: 0x1d00ffff,
|
||||||
|
@ -140,7 +140,7 @@ pub fn genesis_block(network: Network) -> Block {
|
||||||
Block {
|
Block {
|
||||||
header: BlockHeader {
|
header: BlockHeader {
|
||||||
version: 1,
|
version: 1,
|
||||||
prev_blockhash: Default::default(),
|
prev_blockhash: Hash::all_zeros(),
|
||||||
merkle_root,
|
merkle_root,
|
||||||
time: 1598918400,
|
time: 1598918400,
|
||||||
bits: 0x1e0377ae,
|
bits: 0x1e0377ae,
|
||||||
|
@ -153,7 +153,7 @@ pub fn genesis_block(network: Network) -> Block {
|
||||||
Block {
|
Block {
|
||||||
header: BlockHeader {
|
header: BlockHeader {
|
||||||
version: 1,
|
version: 1,
|
||||||
prev_blockhash: Default::default(),
|
prev_blockhash: Hash::all_zeros(),
|
||||||
merkle_root,
|
merkle_root,
|
||||||
time: 1296688602,
|
time: 1296688602,
|
||||||
bits: 0x207fffff,
|
bits: 0x207fffff,
|
||||||
|
@ -194,7 +194,6 @@ impl ChainHash {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use core::default::Default;
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::hashes::hex::{ToHex, FromHex};
|
use crate::hashes::hex::{ToHex, FromHex};
|
||||||
use crate::network::constants::Network;
|
use crate::network::constants::Network;
|
||||||
|
@ -206,7 +205,7 @@ mod test {
|
||||||
|
|
||||||
assert_eq!(gen.version, 1);
|
assert_eq!(gen.version, 1);
|
||||||
assert_eq!(gen.input.len(), 1);
|
assert_eq!(gen.input.len(), 1);
|
||||||
assert_eq!(gen.input[0].previous_output.txid, Default::default());
|
assert_eq!(gen.input[0].previous_output.txid, Hash::all_zeros());
|
||||||
assert_eq!(gen.input[0].previous_output.vout, 0xFFFFFFFF);
|
assert_eq!(gen.input[0].previous_output.vout, 0xFFFFFFFF);
|
||||||
assert_eq!(serialize(&gen.input[0].script_sig),
|
assert_eq!(serialize(&gen.input[0].script_sig),
|
||||||
Vec::from_hex("4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73").unwrap());
|
Vec::from_hex("4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73").unwrap());
|
||||||
|
@ -226,7 +225,7 @@ mod test {
|
||||||
let gen = genesis_block(Network::Bitcoin);
|
let gen = genesis_block(Network::Bitcoin);
|
||||||
|
|
||||||
assert_eq!(gen.header.version, 1);
|
assert_eq!(gen.header.version, 1);
|
||||||
assert_eq!(gen.header.prev_blockhash, Default::default());
|
assert_eq!(gen.header.prev_blockhash, Hash::all_zeros());
|
||||||
assert_eq!(gen.header.merkle_root.to_hex(), "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b");
|
assert_eq!(gen.header.merkle_root.to_hex(), "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b");
|
||||||
|
|
||||||
assert_eq!(gen.header.time, 1231006505);
|
assert_eq!(gen.header.time, 1231006505);
|
||||||
|
@ -239,7 +238,7 @@ mod test {
|
||||||
fn testnet_genesis_full_block() {
|
fn testnet_genesis_full_block() {
|
||||||
let gen = genesis_block(Network::Testnet);
|
let gen = genesis_block(Network::Testnet);
|
||||||
assert_eq!(gen.header.version, 1);
|
assert_eq!(gen.header.version, 1);
|
||||||
assert_eq!(gen.header.prev_blockhash, Default::default());
|
assert_eq!(gen.header.prev_blockhash, Hash::all_zeros());
|
||||||
assert_eq!(gen.header.merkle_root.to_hex(), "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b");
|
assert_eq!(gen.header.merkle_root.to_hex(), "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b");
|
||||||
assert_eq!(gen.header.time, 1296688602);
|
assert_eq!(gen.header.time, 1296688602);
|
||||||
assert_eq!(gen.header.bits, 0x1d00ffff);
|
assert_eq!(gen.header.bits, 0x1d00ffff);
|
||||||
|
@ -251,7 +250,7 @@ mod test {
|
||||||
fn signet_genesis_full_block() {
|
fn signet_genesis_full_block() {
|
||||||
let gen = genesis_block(Network::Signet);
|
let gen = genesis_block(Network::Signet);
|
||||||
assert_eq!(gen.header.version, 1);
|
assert_eq!(gen.header.version, 1);
|
||||||
assert_eq!(gen.header.prev_blockhash, Default::default());
|
assert_eq!(gen.header.prev_blockhash, Hash::all_zeros());
|
||||||
assert_eq!(gen.header.merkle_root.to_hex(), "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b");
|
assert_eq!(gen.header.merkle_root.to_hex(), "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b");
|
||||||
assert_eq!(gen.header.time, 1598918400);
|
assert_eq!(gen.header.time, 1598918400);
|
||||||
assert_eq!(gen.header.bits, 0x1e0377ae);
|
assert_eq!(gen.header.bits, 0x1e0377ae);
|
||||||
|
@ -262,7 +261,7 @@ mod test {
|
||||||
// The *_chain_hash tests are sanity/regression tests, they verify that the const byte array
|
// The *_chain_hash tests are sanity/regression tests, they verify that the const byte array
|
||||||
// representing the genesis block is the same as that created by hashing the genesis block.
|
// representing the genesis block is the same as that created by hashing the genesis block.
|
||||||
fn chain_hash_and_genesis_block(network: Network) {
|
fn chain_hash_and_genesis_block(network: Network) {
|
||||||
use hashes::{sha256, Hash};
|
use crate::hashes::sha256;
|
||||||
|
|
||||||
// The genesis block hash is a double-sha256 and it is displayed backwards.
|
// The genesis block hash is a double-sha256 and it is displayed backwards.
|
||||||
let genesis_hash = genesis_block(network).block_hash();
|
let genesis_hash = genesis_block(network).block_hash();
|
||||||
|
|
|
@ -60,7 +60,7 @@ impl OutPoint {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn null() -> OutPoint {
|
pub fn null() -> OutPoint {
|
||||||
OutPoint {
|
OutPoint {
|
||||||
txid: Default::default(),
|
txid: Hash::all_zeros(),
|
||||||
vout: u32::max_value(),
|
vout: u32::max_value(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
//! hash).
|
//! hash).
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use crate::hashes::{Hash, sha256, sha256d, hash160, hash_newtype};
|
use bitcoin_hashes::{sha256, sha256d, hash160, hash_newtype};
|
||||||
|
|
||||||
macro_rules! impl_hashencode {
|
macro_rules! impl_hashencode {
|
||||||
($hashtype:ident) => {
|
($hashtype:ident) => {
|
||||||
|
|
|
@ -11,7 +11,7 @@ use crate::prelude::*;
|
||||||
|
|
||||||
use crate::io;
|
use crate::io;
|
||||||
|
|
||||||
use crate::hashes::sha256d;
|
use crate::hashes::{Hash as _, sha256d};
|
||||||
|
|
||||||
use crate::network::constants;
|
use crate::network::constants;
|
||||||
use crate::consensus::encode::{self, Decodable, Encodable};
|
use crate::consensus::encode::{self, Decodable, Encodable};
|
||||||
|
@ -50,7 +50,7 @@ impl Encodable for Inventory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(match *self {
|
Ok(match *self {
|
||||||
Inventory::Error => encode_inv!(0, sha256d::Hash::default()),
|
Inventory::Error => encode_inv!(0, sha256d::Hash::all_zeros()),
|
||||||
Inventory::Transaction(ref t) => encode_inv!(1, t),
|
Inventory::Transaction(ref t) => encode_inv!(1, t),
|
||||||
Inventory::Block(ref b) => encode_inv!(2, b),
|
Inventory::Block(ref b) => encode_inv!(2, b),
|
||||||
Inventory::WTx(w) => encode_inv!(5, w),
|
Inventory::WTx(w) => encode_inv!(5, w),
|
||||||
|
@ -139,9 +139,8 @@ mod tests {
|
||||||
use super::{Vec, GetHeadersMessage, GetBlocksMessage};
|
use super::{Vec, GetHeadersMessage, GetBlocksMessage};
|
||||||
|
|
||||||
use crate::hashes::hex::FromHex;
|
use crate::hashes::hex::FromHex;
|
||||||
|
use crate::hashes::Hash;
|
||||||
use crate::consensus::encode::{deserialize, serialize};
|
use crate::consensus::encode::{deserialize, serialize};
|
||||||
use core::default::Default;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn getblocks_message_test() {
|
fn getblocks_message_test() {
|
||||||
|
@ -154,7 +153,7 @@ mod tests {
|
||||||
assert_eq!(real_decode.version, 70002);
|
assert_eq!(real_decode.version, 70002);
|
||||||
assert_eq!(real_decode.locator_hashes.len(), 1);
|
assert_eq!(real_decode.locator_hashes.len(), 1);
|
||||||
assert_eq!(serialize(&real_decode.locator_hashes[0]), genhash);
|
assert_eq!(serialize(&real_decode.locator_hashes[0]), genhash);
|
||||||
assert_eq!(real_decode.stop_hash, Default::default());
|
assert_eq!(real_decode.stop_hash, Hash::all_zeros());
|
||||||
|
|
||||||
assert_eq!(serialize(&real_decode), from_sat);
|
assert_eq!(serialize(&real_decode), from_sat);
|
||||||
}
|
}
|
||||||
|
@ -170,7 +169,7 @@ mod tests {
|
||||||
assert_eq!(real_decode.version, 70002);
|
assert_eq!(real_decode.version, 70002);
|
||||||
assert_eq!(real_decode.locator_hashes.len(), 1);
|
assert_eq!(real_decode.locator_hashes.len(), 1);
|
||||||
assert_eq!(serialize(&real_decode.locator_hashes[0]), genhash);
|
assert_eq!(serialize(&real_decode.locator_hashes[0]), genhash);
|
||||||
assert_eq!(real_decode.stop_hash, Default::default());
|
assert_eq!(real_decode.stop_hash, Hash::all_zeros());
|
||||||
|
|
||||||
assert_eq!(serialize(&real_decode), from_sat);
|
assert_eq!(serialize(&real_decode), from_sat);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1339,8 +1339,8 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_valid_networks() {
|
fn test_valid_networks() {
|
||||||
let legacy_payload = &[
|
let legacy_payload = &[
|
||||||
Payload::PubkeyHash(PubkeyHash::default()),
|
Payload::PubkeyHash(PubkeyHash::all_zeros()),
|
||||||
Payload::ScriptHash(ScriptHash::default())
|
Payload::ScriptHash(ScriptHash::all_zeros())
|
||||||
];
|
];
|
||||||
let segwit_payload = (0..=16).map(|version| {
|
let segwit_payload = (0..=16).map(|version| {
|
||||||
Payload::WitnessProgram {
|
Payload::WitnessProgram {
|
||||||
|
|
|
@ -114,7 +114,7 @@ mod tests {
|
||||||
|
|
||||||
let hashes_iter = block.txdata.iter().map(|obj| obj.txid().as_hash());
|
let hashes_iter = block.txdata.iter().map(|obj| obj.txid().as_hash());
|
||||||
|
|
||||||
let mut hashes_array: [sha256d::Hash; 15] = [Default::default(); 15];
|
let mut hashes_array: [sha256d::Hash; 15] = [Hash::all_zeros(); 15];
|
||||||
for (i, hash) in hashes_iter.clone().enumerate() {
|
for (i, hash) in hashes_iter.clone().enumerate() {
|
||||||
hashes_array[i] = hash;
|
hashes_array[i] = hash;
|
||||||
}
|
}
|
||||||
|
|
|
@ -584,7 +584,7 @@ mod tests {
|
||||||
|
|
||||||
// Check that it has the same merkle root as the original, and a valid one
|
// Check that it has the same merkle root as the original, and a valid one
|
||||||
assert_eq!(merkle_root_1, merkle_root_2);
|
assert_eq!(merkle_root_1, merkle_root_2);
|
||||||
assert_ne!(merkle_root_2, TxMerkleNode::default());
|
assert_ne!(merkle_root_2, TxMerkleNode::all_zeros());
|
||||||
|
|
||||||
// check that it contains the matched transactions (in the same order!)
|
// check that it contains the matched transactions (in the same order!)
|
||||||
assert_eq!(match_txid1, match_txid2);
|
assert_eq!(match_txid1, match_txid2);
|
||||||
|
|
|
@ -382,7 +382,7 @@ mod tests {
|
||||||
fn taptree_hidden() {
|
fn taptree_hidden() {
|
||||||
let mut builder = compose_taproot_builder(0x51, &[2, 2, 2]);
|
let mut builder = compose_taproot_builder(0x51, &[2, 2, 2]);
|
||||||
builder = builder.add_leaf_with_ver(3, Script::from_hex("b9").unwrap(), LeafVersion::from_consensus(0xC2).unwrap()).unwrap();
|
builder = builder.add_leaf_with_ver(3, Script::from_hex("b9").unwrap(), LeafVersion::from_consensus(0xC2).unwrap()).unwrap();
|
||||||
builder = builder.add_hidden_node(3, sha256::Hash::default()).unwrap();
|
builder = builder.add_hidden_node(3, sha256::Hash::all_zeros()).unwrap();
|
||||||
assert!(TapTree::try_from(builder).is_err());
|
assert!(TapTree::try_from(builder).is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -567,7 +567,7 @@ impl<R: Deref<Target = Transaction>> SighashCache<R> {
|
||||||
value: u64,
|
value: u64,
|
||||||
sighash_type: EcdsaSighashType,
|
sighash_type: EcdsaSighashType,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let zero_hash = sha256d::Hash::default();
|
let zero_hash = sha256d::Hash::all_zeros();
|
||||||
|
|
||||||
let (sighash, anyone_can_pay) = sighash_type.split_anyonecanpay_flag();
|
let (sighash, anyone_can_pay) = sighash_type.split_anyonecanpay_flag();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue