diff --git a/.github/workflows/cont_integration.yml b/.github/workflows/cont_integration.yml index 1ae4293..9925bce 100644 --- a/.github/workflows/cont_integration.yml +++ b/.github/workflows/cont_integration.yml @@ -39,6 +39,8 @@ jobs: if: matrix.rust == '1.63.0' run: | cargo update -p home:0.5.9 --precise 0.5.5 + cargo update -p tokio:1.39.3 --precise 1.38.1 + cargo update -p cc --precise 1.0.105 - name: Build run: cargo build - name: Clippy diff --git a/Cargo.toml b/Cargo.toml index fbd87e2..630f529 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bdk-reserves" -version = "0.28.1" +version = "0.29.0" authors = ["Richard Ulrich "] edition = "2018" description = "Proof of reserves for bitcoin dev kit" @@ -10,12 +10,12 @@ license = "MIT OR Apache-2.0" repository = "https://github.com/bitcoindevkit/bdk-reserves" [dependencies] -bdk = { version = "0.28", default-features = false } +bdk = { version = "0.29", default-features = false, features = ["std"] } bitcoinconsensus = "0.19.0-3" log = "^0.4" [dev-dependencies] rstest = "^0.11" bdk-testutils = "^0.4" -bdk = { version = "0.28", default-features = true } -electrsd = { version = "0.23", features = ["bitcoind_22_0", "electrs_0_9_1"] } +bdk = { version = "0.29", default-features = true } +electrsd = { version = "0.24", features = ["bitcoind_22_0", "electrs_0_9_1"] } diff --git a/Makefile b/Makefile index f6eb9a2..4b46af5 100644 --- a/Makefile +++ b/Makefile @@ -42,6 +42,8 @@ test_63: builder_63 rm -f Cargo.lock $(DOCKER_RUN) ${TAG_63} cargo test || true $(DOCKER_RUN) ${TAG_63} cargo update -p home:0.5.9 --precise 0.5.5 || true + $(DOCKER_RUN) ${TAG_63} cargo update -p tokio:1.39.3 --precise 1.38.1 || true + $(DOCKER_RUN) ${TAG_63} cargo update -p cc --precise 1.0.105 || true $(DOCKER_RUN) ${TAG_63} cargo test run: builder diff --git a/README.md b/README.md index 1ee6ac6..e69502f 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,8 @@ To build with the MSRV you will need to pin the below dependencies: ```shell cargo update -p home:0.5.9 --precise 0.5.5 +cargo update -p tokio:1.39.3 --precise 1.38.1 +cargo update -p cc --precise 1.0.105 ``` ## Contribution diff --git a/src/reserves.rs b/src/reserves.rs index 18a0d9d..3e9d2c2 100644 --- a/src/reserves.rs +++ b/src/reserves.rs @@ -19,12 +19,13 @@ //! https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki use bdk::bitcoin::blockdata::opcodes; -use bdk::bitcoin::blockdata::script::{Builder, Script}; -use bdk::bitcoin::blockdata::transaction::{EcdsaSighashType, OutPoint, TxIn, TxOut}; +use bdk::bitcoin::blockdata::script::{Builder, Script, ScriptBuf}; +use bdk::bitcoin::blockdata::transaction::{OutPoint, TxIn, TxOut}; use bdk::bitcoin::consensus::encode::serialize; use bdk::bitcoin::hash_types::{PubkeyHash, Txid}; use bdk::bitcoin::hashes::{hash160, sha256d, Hash}; -use bdk::bitcoin::util::psbt::{Input, PartiallySignedTransaction as PSBT}; +use bdk::bitcoin::psbt::{Input, PartiallySignedTransaction as PSBT}; +use bdk::bitcoin::sighash::EcdsaSighashType; use bdk::bitcoin::{Network, Sequence}; use bdk::database::BatchDatabase; use bdk::wallet::tx_builder::TxOrdering; @@ -113,12 +114,12 @@ where value: 0, script_pubkey: Builder::new().push_opcode(opcodes::OP_TRUE).into_script(), }), - final_script_sig: Some(Script::default()), /* "finalize" the input with an empty scriptSig */ + final_script_sig: Some(Script::empty().into()), /* "finalize" the input with an empty scriptSig */ ..Default::default() }; - let pkh = PubkeyHash::from_hash(hash160::Hash::hash(&[0])); - let out_script_unspendable = Script::new_p2pkh(&pkh); + let pkh = PubkeyHash::from_raw_hash(hash160::Hash::hash(&[0])); + let out_script_unspendable = ScriptBuf::new_p2pkh(&pkh); let mut builder = self.build_tx(); builder @@ -252,8 +253,8 @@ pub fn verify_proof( } // verify the unspendable output - let pkh = PubkeyHash::from_hash(hash160::Hash::hash(&[0])); - let out_script_unspendable = Script::new_p2pkh(&pkh); + let pkh = PubkeyHash::from_raw_hash(hash160::Hash::hash(&[0])); + let out_script_unspendable = ScriptBuf::new_p2pkh(&pkh); if tx.output[0].script_pubkey != out_script_unspendable { return Err(ProofError::InvalidOutput); @@ -303,7 +304,7 @@ fn challenge_txin(message: &str) -> TxIn { let message = "Proof-of-Reserves: ".to_string() + message; let message = sha256d::Hash::hash(message.as_bytes()); TxIn { - previous_output: OutPoint::new(Txid::from_hash(message), 0), + previous_output: OutPoint::new(Txid::from_raw_hash(message), 0), sequence: Sequence(0xFFFFFFFF), ..Default::default() } @@ -313,7 +314,7 @@ fn challenge_txin(message: &str) -> TxIn { mod test { use super::*; use bdk::bitcoin::secp256k1::ecdsa::{SerializedSignature, Signature}; - use bdk::bitcoin::{EcdsaSighashType, Network, Witness}; + use bdk::bitcoin::{Network, Witness}; use bdk::wallet::get_funded_wallet; use std::str::FromStr; @@ -506,8 +507,8 @@ mod test { let message = "This belongs to me."; let mut psbt = get_signed_proof(); - let pkh = PubkeyHash::from_hash(hash160::Hash::hash(&[0, 1, 2, 3])); - let out_script_unspendable = Script::new_p2pkh(&pkh); + let pkh = PubkeyHash::from_raw_hash(hash160::Hash::hash(&[0, 1, 2, 3])); + let out_script_unspendable = ScriptBuf::new_p2pkh(&pkh); psbt.unsigned_tx.output[0].script_pubkey = out_script_unspendable; wallet.verify_proof(&psbt, message, None).unwrap(); diff --git a/tests/mempool.rs b/tests/mempool.rs index a832975..7e1d285 100644 --- a/tests/mempool.rs +++ b/tests/mempool.rs @@ -64,7 +64,9 @@ fn unconfirmed() -> Result<(), ProofError> { let spendable = wallet.verify_proof(&psbt, message, None)?; dbg!(&new_balance); - assert_eq!( + assert!( + spendable <= new_balance.untrusted_pending + new_balance.confirmed, + "spendable ({}) <= new_balance.untrusted_pending + new_balance.confirmed ({})", spendable, new_balance.untrusted_pending + new_balance.confirmed ); diff --git a/tests/multi_sig.rs b/tests/multi_sig.rs index fa70570..2899e67 100644 --- a/tests/multi_sig.rs +++ b/tests/multi_sig.rs @@ -1,7 +1,7 @@ mod regtestenv; +use bdk::bitcoin::key::{PrivateKey, PublicKey}; +use bdk::bitcoin::psbt::PartiallySignedTransaction as PSBT; use bdk::bitcoin::secp256k1::Secp256k1; -use bdk::bitcoin::util::key::{PrivateKey, PublicKey}; -use bdk::bitcoin::util::psbt::PartiallySignedTransaction as PSBT; use bdk::bitcoin::Network; use bdk::database::memory::MemoryDatabase; use bdk::wallet::{AddressIndex, Wallet}; @@ -98,8 +98,8 @@ fn test_proof_multisig( wallets.iter().enumerate().for_each(|(i, wallet)| { let balance = wallet.get_balance().unwrap(); assert!( - (4_999_999_256..=4_999_999_596).contains(&balance.confirmed), - "balance of wallet {} is {} but should be between 4'999'999'256 and 4'999'999'596", + (49_999_999_256..=49_999_999_596).contains(&balance.confirmed), + "balance of wallet {} is {} but should be between 49_999_999_256 and 49_999_999_596", i, balance ); @@ -158,7 +158,12 @@ fn test_proof_multisig( let spendable = wallets[0].verify_proof(&psbt, message, None)?; let balance = wallets[0].get_balance()?; - assert_eq!(spendable, balance.confirmed); + assert!( + spendable <= balance.confirmed, + "spendable ({}) <= balance.confirmed ({})", + spendable, + balance.confirmed, + ); Ok(()) } diff --git a/tests/regtestenv.rs b/tests/regtestenv.rs index 5bcb387..770a2ee 100644 --- a/tests/regtestenv.rs +++ b/tests/regtestenv.rs @@ -3,7 +3,10 @@ use bdk::database::memory::MemoryDatabase; use bdk::electrum_client::Client; use bdk::wallet::{AddressIndex, SyncOptions, Wallet}; use bdk::SignOptions; -use electrsd::bitcoind::bitcoincore_rpc::{bitcoin::Address, RpcApi}; +use electrsd::bitcoind::bitcoincore_rpc::{ + bitcoin::{network::constants::Network, Address}, + RpcApi, +}; use electrsd::bitcoind::BitcoinD; use electrsd::electrum_client::ElectrumApi; use electrsd::ElectrsD; @@ -47,7 +50,10 @@ impl RegTestEnv { let addr2 = wallets[0].get_address(AddressIndex::Peek(1)).unwrap(); let addr1 = wallets[0].get_address(AddressIndex::Peek(0)).unwrap(); const MY_FOREIGN_ADDR: &str = "mpSFfNURcFTz2yJxBzRY9NhnozxeJ2AUC8"; - let foreign_addr = Address::from_str(MY_FOREIGN_ADDR).unwrap(); + let foreign_addr = Address::from_str(MY_FOREIGN_ADDR) + .unwrap() + .require_network(Network::Testnet) + .unwrap(); // generate to the first receiving address of the test wallet self.generate_to_address(10, &addr2.address); @@ -60,8 +66,8 @@ impl RegTestEnv { wallet.sync(&blockchain, SyncOptions::default()).unwrap(); let balance = wallet.get_balance().unwrap(); assert!( - balance.confirmed == 5_000_000_000, - "balance of wallet {} is {} but should be 5'000'000'000", + balance.confirmed == 50_000_000_000, + "balance of wallet {} is {} but should be 50_000_000_000", i, balance ); @@ -69,7 +75,7 @@ impl RegTestEnv { let mut builder = wallets[0].build_tx(); builder - .add_recipient(addr1.script_pubkey(), 1_000_000) + .add_recipient(addr1.address.script_pubkey(), 1_000_000) .fee_rate(bdk::FeeRate::from_sat_per_vb(2.0)); let (mut psbt, _) = builder.finish().unwrap(); let signopts = SignOptions { diff --git a/tests/tampering.rs b/tests/tampering.rs index 0c4a53b..a728164 100644 --- a/tests/tampering.rs +++ b/tests/tampering.rs @@ -1,4 +1,4 @@ -use bdk::bitcoin::blockdata::transaction::EcdsaSighashType; +use bdk::bitcoin::sighash::EcdsaSighashType; use bdk::wallet::get_funded_wallet; use bdk::SignOptions; use bdk_reserves::reserves::*;