diff --git a/Cargo.toml b/Cargo.toml index c90883f..fe6a5f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bdk-reserves" -version = "0.16.0" +version = "0.17.0" authors = ["Richard Ulrich "] edition = "2018" description = "Proof of reserves for bitcoin dev kit" @@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0" repository = "https://github.com/weareseba/bdk-reserves" [dependencies] -bdk = { version = "^0.16", default-features = false } +bdk = { version = "^0.17", default-features = false } bitcoinconsensus = "0.19.0-3" base64 = "^0.11" log = "^0.4" @@ -18,4 +18,4 @@ log = "^0.4" [dev-dependencies] rstest = "^0.11" bdk-testutils = "^0.4" -bdk = { version = "^0.16", default-features = true } +bdk = { version = "^0.17", default-features = true } diff --git a/src/reserves.rs b/src/reserves.rs index 305880e..1bf90fc 100644 --- a/src/reserves.rs +++ b/src/reserves.rs @@ -100,7 +100,7 @@ impl From for bdk::Error { } } -impl ProofOfReserves for Wallet +impl ProofOfReserves for Wallet where D: BatchDatabase, { diff --git a/tests/mempool.rs b/tests/mempool.rs index f1fea7a..99f791f 100644 --- a/tests/mempool.rs +++ b/tests/mempool.rs @@ -1,8 +1,8 @@ use bdk::bitcoin::Network; -use bdk::blockchain::{noop_progress, Blockchain, ElectrumBlockchain}; +use bdk::blockchain::{electrum::ElectrumBlockchain, Blockchain, GetHeight}; use bdk::database::memory::MemoryDatabase; use bdk::electrum_client::Client; -use bdk::wallet::{AddressIndex, Wallet}; +use bdk::wallet::{AddressIndex, SyncOptions, Wallet}; use bdk::Error; use bdk::SignOptions; use bdk_reserves::reserves::*; @@ -10,24 +10,19 @@ use bdk_reserves::reserves::*; fn construct_wallet( desc: &str, network: Network, -) -> Result, Error> { +) -> Result<(Wallet, ElectrumBlockchain), Error> { let client = Client::new("ssl://electrum.blockstream.info:60002")?; - let wallet = Wallet::new( - desc, - None, - network, - MemoryDatabase::default(), - ElectrumBlockchain::from(client), - )?; + let wallet = Wallet::new(desc, None, network, MemoryDatabase::default())?; - wallet.sync(noop_progress(), None)?; + let blockchain = ElectrumBlockchain::from(client); + wallet.sync(&blockchain, SyncOptions::default())?; - Ok(wallet) + Ok((wallet, blockchain)) } #[test] fn unconfirmed() -> Result<(), ProofError> { - let wallet = construct_wallet( + let (wallet, blockchain) = construct_wallet( "wpkh(cTTgG6x13nQjAeECaCaDrjrUdcjReZBGspcmNavsnSRyXq7zXT7r)", Network::Testnet, )?; @@ -51,8 +46,8 @@ fn unconfirmed() -> Result<(), ProofError> { }; let finalized = wallet.sign(&mut psbt, signopts.clone())?; assert!(finalized); - wallet.broadcast(&psbt.extract_tx())?; - wallet.sync(noop_progress(), None)?; + blockchain.broadcast(&psbt.extract_tx())?; + wallet.sync(&blockchain, SyncOptions::default())?; let new_balance = wallet.get_balance()?; assert_ne!(balance, new_balance); @@ -71,7 +66,7 @@ fn unconfirmed() -> Result<(), ProofError> { #[test] #[should_panic(expected = "NonSpendableInput")] fn confirmed() { - let wallet = construct_wallet( + let (wallet, blockchain) = construct_wallet( "wpkh(cTTgG6x13nQjAeECaCaDrjrUdcjReZBGspcmNavsnSRyXq7zXT7r)", Network::Testnet, ) @@ -96,8 +91,8 @@ fn confirmed() { }; let finalized = wallet.sign(&mut psbt, signopts.clone()).unwrap(); assert!(finalized); - wallet.broadcast(&psbt.extract_tx()).unwrap(); - wallet.sync(noop_progress(), None).unwrap(); + blockchain.broadcast(&psbt.extract_tx()).unwrap(); + wallet.sync(&blockchain, SyncOptions::default()).unwrap(); let new_balance = wallet.get_balance().unwrap(); assert_ne!(balance, new_balance); @@ -108,7 +103,7 @@ fn confirmed() { assert!(finalized); const CONFIRMATIONS: u32 = 2; - let current_height = wallet.client().get_height().unwrap(); + let current_height = blockchain.get_height().unwrap(); let max_confirmation_height = current_height - CONFIRMATIONS; let spendable = wallet diff --git a/tests/multi_sig.rs b/tests/multi_sig.rs index df376cb..e2e6e00 100644 --- a/tests/multi_sig.rs +++ b/tests/multi_sig.rs @@ -2,10 +2,10 @@ 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::blockchain::{noop_progress, ElectrumBlockchain}; +use bdk::blockchain::electrum::ElectrumBlockchain; use bdk::database::memory::MemoryDatabase; use bdk::electrum_client::Client; -use bdk::wallet::{AddressIndex, Wallet}; +use bdk::wallet::{AddressIndex, SyncOptions, Wallet}; use bdk::Error; use bdk::SignOptions; use bdk_reserves::reserves::*; @@ -21,7 +21,7 @@ fn construct_multisig_wallet( signer: &PrivateKey, pubkeys: &[PublicKey], script_type: &MultisigType, -) -> Result, Error> { +) -> Result, Error> { let secp = Secp256k1::new(); let pub_derived = signer.public_key(&secp); @@ -46,15 +46,10 @@ fn construct_multisig_wallet( }) + &postfix; let client = Client::new("ssl://electrum.blockstream.info:60002")?; - let wallet = Wallet::new( - &desc, - None, - Network::Testnet, - MemoryDatabase::default(), - ElectrumBlockchain::from(client), - )?; - - wallet.sync(noop_progress(), None)?; + let wallet = Wallet::new(&desc, None, Network::Testnet, MemoryDatabase::default())?; + + let blockchain = ElectrumBlockchain::from(client); + wallet.sync(&blockchain, SyncOptions::default())?; Ok(wallet) }