Merge rust-bitcoin/rust-bitcoin#1432: Hotfix: Fix broken serde
5fc40baa73
Fix new clippy warnings (sanket1729)3a923980e1
Hotfix: Fix broken serde (sanket1729) Pull request description: My local scripts did not test serde feature on the merge commit. While merging #734, I accidentally broke the serde feature on the latest master. This PR fixes it. Sorry about that, I will update my local script to be the same as of CI check. ACKs for top commit: tcharding: ACK5fc40baa73
Kixunil: ACK5fc40baa73
Tree-SHA512: 99d348262239c53ab86ecf66bc64461958f181df0c102beddae486c813ab6d0c7a0b5af505fa5c7e60d5b59554e0bcf8547a71bf713020ddee1cc3d4b3a631f4
This commit is contained in:
commit
55b93e95f5
|
@ -26,20 +26,20 @@ use std::collections::BTreeMap;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use bincode::serialize;
|
use bincode::serialize;
|
||||||
|
use bitcoin::bip32::{ChildNumber, ExtendedPrivKey, ExtendedPubKey, KeySource};
|
||||||
use bitcoin::blockdata::locktime::{absolute, relative};
|
use bitcoin::blockdata::locktime::{absolute, relative};
|
||||||
use bitcoin::blockdata::witness::Witness;
|
use bitcoin::blockdata::witness::Witness;
|
||||||
use bitcoin::consensus::encode::deserialize;
|
use bitcoin::consensus::encode::deserialize;
|
||||||
use bitcoin::hashes::hex::FromHex;
|
use bitcoin::hashes::hex::FromHex;
|
||||||
use bitcoin::hashes::{hash160, ripemd160, sha256, sha256d, Hash};
|
use bitcoin::hashes::{hash160, ripemd160, sha256, sha256d, Hash};
|
||||||
|
use bitcoin::psbt::raw::{self, Key, Pair, ProprietaryKey};
|
||||||
|
use bitcoin::psbt::{Input, Output, Psbt, PsbtSighashType};
|
||||||
|
use bitcoin::schnorr::{self, UntweakedPublicKey};
|
||||||
use bitcoin::sighash::{EcdsaSighashType, SchnorrSighashType};
|
use bitcoin::sighash::{EcdsaSighashType, SchnorrSighashType};
|
||||||
use bitcoin::util::bip32::{ChildNumber, ExtendedPrivKey, ExtendedPubKey, KeySource};
|
use bitcoin::taproot::{ControlBlock, LeafVersion, TaprootBuilder, TaprootSpendInfo};
|
||||||
use bitcoin::util::psbt::raw::{self, Key, Pair, ProprietaryKey};
|
|
||||||
use bitcoin::util::psbt::{Input, Output, Psbt, PsbtSighashType};
|
|
||||||
use bitcoin::util::schnorr::UntweakedPublicKey;
|
|
||||||
use bitcoin::util::taproot::{ControlBlock, LeafVersion, TaprootBuilder, TaprootSpendInfo};
|
|
||||||
use bitcoin::{
|
use bitcoin::{
|
||||||
Address, Block, EcdsaSig, Network, OutPoint, PrivateKey, PublicKey, SchnorrSig, Script,
|
ecdsa, Address, Block, Network, OutPoint, PrivateKey, PublicKey, Script, Sequence, Target,
|
||||||
Sequence, Target, Transaction, TxIn, TxOut, Txid, Work,
|
Transaction, TxIn, TxOut, Txid, Work,
|
||||||
};
|
};
|
||||||
use secp256k1::Secp256k1;
|
use secp256k1::Secp256k1;
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ fn serde_regression_witness() {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let w1 = Vec::from_hex("000000").unwrap();
|
let w1 = Vec::from_hex("000000").unwrap();
|
||||||
let vec = vec![w0, w1];
|
let vec = vec![w0, w1];
|
||||||
let witness = Witness::from_vec(vec);
|
let witness = Witness::from_slice(&vec);
|
||||||
|
|
||||||
let got = serialize(&witness).unwrap();
|
let got = serialize(&witness).unwrap();
|
||||||
let want = include_bytes!("data/serde/witness_bincode") as &[_];
|
let want = include_bytes!("data/serde/witness_bincode") as &[_];
|
||||||
|
@ -174,7 +174,7 @@ fn serde_regression_extended_pub_key() {
|
||||||
#[test]
|
#[test]
|
||||||
fn serde_regression_ecdsa_sig() {
|
fn serde_regression_ecdsa_sig() {
|
||||||
let s = include_str!("data/serde/ecdsa_sig_hex");
|
let s = include_str!("data/serde/ecdsa_sig_hex");
|
||||||
let sig = EcdsaSig {
|
let sig = ecdsa::Signature {
|
||||||
sig: secp256k1::ecdsa::Signature::from_str(s.trim()).unwrap(),
|
sig: secp256k1::ecdsa::Signature::from_str(s.trim()).unwrap(),
|
||||||
hash_ty: EcdsaSighashType::All,
|
hash_ty: EcdsaSighashType::All,
|
||||||
};
|
};
|
||||||
|
@ -234,7 +234,7 @@ fn serde_regression_psbt() {
|
||||||
},
|
},
|
||||||
script_sig: Script::from_str("160014be18d152a9b012039daf3da7de4f53349eecb985").unwrap(),
|
script_sig: Script::from_str("160014be18d152a9b012039daf3da7de4f53349eecb985").unwrap(),
|
||||||
sequence: Sequence::from_consensus(4294967295),
|
sequence: Sequence::from_consensus(4294967295),
|
||||||
witness: Witness::from_vec(vec![Vec::from_hex(
|
witness: Witness::from_slice(&[Vec::from_hex(
|
||||||
"03d2e15674941bad4a996372cb87e1856d3652606d98562fe39c5e9e7e413f2105",
|
"03d2e15674941bad4a996372cb87e1856d3652606d98562fe39c5e9e7e413f2105",
|
||||||
)
|
)
|
||||||
.unwrap()]),
|
.unwrap()]),
|
||||||
|
@ -296,7 +296,7 @@ fn serde_regression_psbt() {
|
||||||
"304402204f67e2afb76142d44fae58a2495d33a3419daa26cd0db8d04f3452b63289ac0f022010762a9fb67e94cc5cad9026f6dc99ff7f070f4278d30fbc7d0c869dd38c7fe701".parse().unwrap(),
|
"304402204f67e2afb76142d44fae58a2495d33a3419daa26cd0db8d04f3452b63289ac0f022010762a9fb67e94cc5cad9026f6dc99ff7f070f4278d30fbc7d0c869dd38c7fe701".parse().unwrap(),
|
||||||
)].into_iter().collect(),
|
)].into_iter().collect(),
|
||||||
bip32_derivation: keypaths.clone().into_iter().collect(),
|
bip32_derivation: keypaths.clone().into_iter().collect(),
|
||||||
final_script_witness: Some(Witness::from_vec(vec![vec![1, 3], vec![5]])),
|
final_script_witness: Some(Witness::from_slice(&[vec![1, 3], vec![5]])),
|
||||||
ripemd160_preimages: vec![(ripemd160::Hash::hash(&[]), vec![1, 2])].into_iter().collect(),
|
ripemd160_preimages: vec![(ripemd160::Hash::hash(&[]), vec![1, 2])].into_iter().collect(),
|
||||||
sha256_preimages: vec![(sha256::Hash::hash(&[]), vec![1, 2])].into_iter().collect(),
|
sha256_preimages: vec![(sha256::Hash::hash(&[]), vec![1, 2])].into_iter().collect(),
|
||||||
hash160_preimages: vec![(hash160::Hash::hash(&[]), vec![1, 2])].into_iter().collect(),
|
hash160_preimages: vec![(hash160::Hash::hash(&[]), vec![1, 2])].into_iter().collect(),
|
||||||
|
@ -344,7 +344,7 @@ fn serde_regression_proprietary_key() {
|
||||||
#[test]
|
#[test]
|
||||||
fn serde_regression_schnorr_sig() {
|
fn serde_regression_schnorr_sig() {
|
||||||
let s = include_str!("data/serde/schnorr_sig_hex");
|
let s = include_str!("data/serde/schnorr_sig_hex");
|
||||||
let sig = SchnorrSig {
|
let sig = schnorr::Signature {
|
||||||
sig: secp256k1::schnorr::Signature::from_str(s.trim()).unwrap(),
|
sig: secp256k1::schnorr::Signature::from_str(s.trim()).unwrap(),
|
||||||
hash_ty: SchnorrSighashType::All,
|
hash_ty: SchnorrSighashType::All,
|
||||||
};
|
};
|
||||||
|
|
|
@ -469,7 +469,7 @@ mod tests {
|
||||||
|
|
||||||
for test in tests {
|
for test in tests {
|
||||||
// Hash through high-level API, check hex encoding/decoding
|
// Hash through high-level API, check hex encoding/decoding
|
||||||
let hash = ripemd160::Hash::hash(&test.input.as_bytes());
|
let hash = ripemd160::Hash::hash(test.input.as_bytes());
|
||||||
assert_eq!(hash, ripemd160::Hash::from_hex(test.output_str).expect("parse hex"));
|
assert_eq!(hash, ripemd160::Hash::from_hex(test.output_str).expect("parse hex"));
|
||||||
assert_eq!(&hash[..], &test.output[..]);
|
assert_eq!(&hash[..], &test.output[..]);
|
||||||
assert_eq!(&hash.to_hex(), &test.output_str);
|
assert_eq!(&hash.to_hex(), &test.output_str);
|
||||||
|
|
|
@ -195,7 +195,7 @@ mod tests {
|
||||||
|
|
||||||
for test in tests {
|
for test in tests {
|
||||||
// Hash through high-level API, check hex encoding/decoding
|
// Hash through high-level API, check hex encoding/decoding
|
||||||
let hash = sha1::Hash::hash(&test.input.as_bytes());
|
let hash = sha1::Hash::hash(test.input.as_bytes());
|
||||||
assert_eq!(hash, sha1::Hash::from_hex(test.output_str).expect("parse hex"));
|
assert_eq!(hash, sha1::Hash::from_hex(test.output_str).expect("parse hex"));
|
||||||
assert_eq!(&hash[..], &test.output[..]);
|
assert_eq!(&hash[..], &test.output[..]);
|
||||||
assert_eq!(&hash.to_hex(), &test.output_str);
|
assert_eq!(&hash.to_hex(), &test.output_str);
|
||||||
|
|
|
@ -371,7 +371,7 @@ mod tests {
|
||||||
|
|
||||||
for test in tests {
|
for test in tests {
|
||||||
// Hash through high-level API, check hex encoding/decoding
|
// Hash through high-level API, check hex encoding/decoding
|
||||||
let hash = sha256::Hash::hash(&test.input.as_bytes());
|
let hash = sha256::Hash::hash(test.input.as_bytes());
|
||||||
assert_eq!(hash, sha256::Hash::from_hex(test.output_str).expect("parse hex"));
|
assert_eq!(hash, sha256::Hash::from_hex(test.output_str).expect("parse hex"));
|
||||||
assert_eq!(&hash[..], &test.output[..]);
|
assert_eq!(&hash[..], &test.output[..]);
|
||||||
assert_eq!(&hash.to_hex(), &test.output_str);
|
assert_eq!(&hash.to_hex(), &test.output_str);
|
||||||
|
|
|
@ -74,7 +74,7 @@ mod tests {
|
||||||
|
|
||||||
for test in tests {
|
for test in tests {
|
||||||
// Hash through high-level API, check hex encoding/decoding
|
// Hash through high-level API, check hex encoding/decoding
|
||||||
let hash = sha256d::Hash::hash(&test.input.as_bytes());
|
let hash = sha256d::Hash::hash(test.input.as_bytes());
|
||||||
assert_eq!(hash, sha256d::Hash::from_hex(test.output_str).expect("parse hex"));
|
assert_eq!(hash, sha256d::Hash::from_hex(test.output_str).expect("parse hex"));
|
||||||
assert_eq!(&hash[..], &test.output[..]);
|
assert_eq!(&hash[..], &test.output[..]);
|
||||||
assert_eq!(&hash.to_hex(), &test.output_str);
|
assert_eq!(&hash.to_hex(), &test.output_str);
|
||||||
|
|
|
@ -368,7 +368,7 @@ mod tests {
|
||||||
|
|
||||||
for test in tests {
|
for test in tests {
|
||||||
// Hash through high-level API, check hex encoding/decoding
|
// Hash through high-level API, check hex encoding/decoding
|
||||||
let hash = sha512::Hash::hash(&test.input.as_bytes());
|
let hash = sha512::Hash::hash(test.input.as_bytes());
|
||||||
assert_eq!(hash, sha512::Hash::from_hex(test.output_str).expect("parse hex"));
|
assert_eq!(hash, sha512::Hash::from_hex(test.output_str).expect("parse hex"));
|
||||||
assert_eq!(&hash[..], &test.output[..]);
|
assert_eq!(&hash[..], &test.output[..]);
|
||||||
assert_eq!(&hash.to_hex(), &test.output_str);
|
assert_eq!(&hash.to_hex(), &test.output_str);
|
||||||
|
|
Loading…
Reference in New Issue