Skip to content

Commit

Permalink
bumped to v0.17 along with bdk
Browse files Browse the repository at this point in the history
  • Loading branch information
ulrichard committed Mar 31, 2022
1 parent 80a5934 commit 36be556
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 35 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bdk-reserves"
version = "0.16.0"
version = "0.17.0"
authors = ["Richard Ulrich <[email protected]>"]
edition = "2018"
description = "Proof of reserves for bitcoin dev kit"
Expand All @@ -10,12 +10,12 @@ 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"

[dev-dependencies]
rstest = "^0.11"
bdk-testutils = "^0.4"
bdk = { version = "^0.16", default-features = true }
bdk = { version = "^0.17", default-features = true }
2 changes: 1 addition & 1 deletion src/reserves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl From<ProofError> for bdk::Error {
}
}

impl<B, D> ProofOfReserves for Wallet<B, D>
impl<D> ProofOfReserves for Wallet<D>
where
D: BatchDatabase,
{
Expand Down
33 changes: 14 additions & 19 deletions tests/mempool.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
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::*;

fn construct_wallet(
desc: &str,
network: Network,
) -> Result<Wallet<ElectrumBlockchain, MemoryDatabase>, Error> {
) -> Result<(Wallet<MemoryDatabase>, 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,
)?;
Expand All @@ -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);
Expand All @@ -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,
)
Expand All @@ -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);
Expand All @@ -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
Expand Down
19 changes: 7 additions & 12 deletions tests/multi_sig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand All @@ -21,7 +21,7 @@ fn construct_multisig_wallet(
signer: &PrivateKey,
pubkeys: &[PublicKey],
script_type: &MultisigType,
) -> Result<Wallet<ElectrumBlockchain, MemoryDatabase>, Error> {
) -> Result<Wallet<MemoryDatabase>, Error> {
let secp = Secp256k1::new();
let pub_derived = signer.public_key(&secp);

Expand All @@ -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)
}
Expand Down

0 comments on commit 36be556

Please sign in to comment.