diff --git a/dlc-manager/benches/benchmarks.rs b/dlc-manager/benches/benchmarks.rs index bfd6641d..1ea1fc98 100644 --- a/dlc-manager/benches/benchmarks.rs +++ b/dlc-manager/benches/benchmarks.rs @@ -1,6 +1,6 @@ use bitcoin::hashes::Hash; use bitcoin::OutPoint; -use bitcoin::Script; +use bitcoin::ScriptBuf; use bitcoin::WPubkeyHash; use criterion::{black_box, criterion_group, criterion_main, Criterion}; use dlc::create_dlc_transactions; @@ -138,8 +138,8 @@ fn get_pubkey() -> secp256k1_zkp::PublicKey { secp256k1_zkp::PublicKey::from_secret_key(SECP256K1, &SecretKey::new(&mut thread_rng())) } -fn get_p2wpkh_script_pubkey() -> Script { - Script::new_v0_p2wpkh(&WPubkeyHash::hash(&get_pubkey().serialize())) +fn get_p2wpkh_script_pubkey() -> ScriptBuf { + ScriptBuf::new_v0_p2wpkh(&WPubkeyHash::hash(&get_pubkey().serialize())) } fn create_oracle_announcements() -> Vec { @@ -174,7 +174,7 @@ fn create_contract_info() -> ContractInfo { fn create_txinputinfo_vec() -> Vec { let tx_input_info = TxInputInfo { outpoint: OutPoint::default(), - redeem_script: Script::new(), + redeem_script: ScriptBuf::new(), max_witness_len: 108, serial_id: 2, }; diff --git a/dlc/benches/benchmarks.rs b/dlc/benches/benchmarks.rs index 5be2d700..e82ac30b 100644 --- a/dlc/benches/benchmarks.rs +++ b/dlc/benches/benchmarks.rs @@ -11,12 +11,12 @@ extern crate test; #[cfg(all(test, feature = "unstable"))] mod benches { - use bitcoin::{Script, Transaction}; + use bitcoin::{ScriptBuf, Transaction}; use bitcoin_test_utils::tx_from_string; use dlc::*; use rayon::prelude::*; use secp256k1_zkp::{ - global::SECP256K1, rand::thread_rng, rand::RngCore, Message, PublicKey, SecretKey, + global::SECP256K1, rand::thread_rng, rand::RngCore, KeyPair, Message, PublicKey, SecretKey, }; use test::{black_box, Bencher}; @@ -28,10 +28,17 @@ mod benches { const ALL_BASE: usize = 2; fn generate_oracle_info(nb_nonces: usize) -> OracleInfo { - let public_key = SECP256K1.generate_schnorrsig_keypair(&mut thread_rng()).1; + let public_key = KeyPair::new(SECP256K1, &mut thread_rng()) + .x_only_public_key() + .0; + let mut nonces = Vec::with_capacity(nb_nonces); for _ in 0..nb_nonces { - nonces.push(SECP256K1.generate_schnorrsig_keypair(&mut thread_rng()).1); + nonces.push( + KeyPair::new(SECP256K1, &mut thread_rng()) + .x_only_public_key() + .0, + ); } OracleInfo { public_key, nonces } @@ -116,7 +123,7 @@ mod benches { tx_from_string("02000000019246862ea34db0833bd4bd9e657d61e2e5447d0438f6f6181d1cd329e8cf71c30000000000ffffffff02603bea0b000000001600145dedfbf9ea599dd4e3ca6a80b333c472fd0b3f69a0860100000000001600149652d86bedf43ad264362e6e6eba6eb76450812700000000") } - fn funding_script_pubkey() -> Script { + fn funding_script_pubkey() -> ScriptBuf { let seckey = SecretKey::new(&mut thread_rng()); make_funding_redeemscript( &PublicKey::from_secret_key(SECP256K1, &seckey),