Skip to content

Commit 02fa340

Browse files
committed
chore: remove bdk dependency on log and dev dependency on env_logger
1 parent 46d39be commit 02fa340

File tree

8 files changed

+7
-60
lines changed

8 files changed

+7
-60
lines changed

crates/bdk/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ edition = "2021"
1313
rust-version = "1.57"
1414

1515
[dependencies]
16-
log = "0.4"
1716
rand = "^0.8"
1817
miniscript = { version = "10.0.0", features = ["serde"], default-features = false }
1918
bitcoin = { version = "0.30.0", features = ["serde", "base64", "rand-std"], default-features = false }
@@ -45,7 +44,6 @@ dev-getrandom-wasm = ["getrandom/js"]
4544

4645
[dev-dependencies]
4746
lazy_static = "1.4"
48-
env_logger = "0.7"
4947
assert_matches = "1.5.0"
5048
tempfile = "3"
5149
bdk_file_store = { path = "../file_store" }

crates/bdk/examples/compiler.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@
1111

1212
extern crate bdk;
1313
extern crate bitcoin;
14-
extern crate log;
1514
extern crate miniscript;
1615
extern crate serde_json;
1716

1817
use std::error::Error;
1918
use std::str::FromStr;
2019

21-
use log::info;
22-
2320
use bitcoin::Network;
2421
use miniscript::policy::Concrete;
2522
use miniscript::Descriptor;
@@ -36,13 +33,9 @@ use bdk::{KeychainKind, Wallet};
3633
/// This example demonstrates the interaction between a bdk wallet and miniscript policy.
3734
3835
fn main() -> Result<(), Box<dyn Error>> {
39-
env_logger::init_from_env(
40-
env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"),
41-
);
42-
4336
// We start with a generic miniscript policy string
4437
let policy_str = "or(10@thresh(4,pk(029ffbe722b147f3035c87cb1c60b9a5947dd49c774cc31e94773478711a929ac0),pk(025f05815e3a1a8a83bfbb03ce016c9a2ee31066b98f567f6227df1d76ec4bd143),pk(025625f41e4a065efc06d5019cbbd56fe8c07595af1231e7cbc03fafb87ebb71ec),pk(02a27c8b850a00f67da3499b60562673dcf5fdfb82b7e17652a7ac54416812aefd),pk(03e618ec5f384d6e19ca9ebdb8e2119e5bef978285076828ce054e55c4daf473e2)),1@and(older(4209713),thresh(2,pk(03deae92101c790b12653231439f27b8897264125ecb2f46f48278603102573165),pk(033841045a531e1adf9910a6ec279589a90b3b8a904ee64ffd692bd08a8996c1aa),pk(02aebf2d10b040eb936a6f02f44ee82f8b34f5c1ccb20ff3949c2b28206b7c1068))))";
45-
info!("Compiling policy: \n{}", policy_str);
38+
println!("Compiling policy: \n{}", policy_str);
4639

4740
// Parse the string as a [`Concrete`] type miniscript policy.
4841
let policy = Concrete::<String>::from_str(policy_str)?;
@@ -51,20 +44,20 @@ fn main() -> Result<(), Box<dyn Error>> {
5144
// `policy.compile()` returns the resulting miniscript from the policy.
5245
let descriptor = Descriptor::new_wsh(policy.compile()?)?;
5346

54-
info!("Compiled into following Descriptor: \n{}", descriptor);
47+
println!("Compiled into following Descriptor: \n{}", descriptor);
5548

5649
// Create a new wallet from this descriptor
5750
let mut wallet = Wallet::new_no_persist(&format!("{}", descriptor), None, Network::Regtest)?;
5851

59-
info!(
52+
println!(
6053
"First derived address from the descriptor: \n{}",
6154
wallet.get_address(New)
6255
);
6356

6457
// BDK also has it's own `Policy` structure to represent the spending condition in a more
6558
// human readable json format.
6659
let spending_policy = wallet.policies(KeychainKind::External)?;
67-
info!(
60+
println!(
6861
"The BDK spending policy: \n{}",
6962
serde_json::to_string_pretty(&spending_policy)?
7063
);

crates/bdk/examples/policy.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
// licenses.
1111

1212
extern crate bdk;
13-
extern crate env_logger;
14-
extern crate log;
1513
use std::error::Error;
1614

1715
use bdk::bitcoin::Network;
@@ -29,10 +27,6 @@ use bdk::wallet::signer::SignersContainer;
2927
/// one of the Extend Private key.
3028
3129
fn main() -> Result<(), Box<dyn Error>> {
32-
env_logger::init_from_env(
33-
env_logger::Env::default().filter_or(env_logger::DEFAULT_FILTER_ENV, "info"),
34-
);
35-
3630
let secp = bitcoin::secp256k1::Secp256k1::new();
3731

3832
// The descriptor used in the example
@@ -48,7 +42,7 @@ fn main() -> Result<(), Box<dyn Error>> {
4842
// But they can be used as independent tools also.
4943
let (wallet_desc, keymap) = desc.into_wallet_descriptor(&secp, Network::Testnet)?;
5044

51-
log::info!("Example Descriptor for policy analysis : {}", wallet_desc);
45+
println!("Example Descriptor for policy analysis : {}", wallet_desc);
5246

5347
// Create the signer with the keymap and descriptor.
5448
let signers_container = SignersContainer::build(keymap, &wallet_desc, &secp);
@@ -60,7 +54,7 @@ fn main() -> Result<(), Box<dyn Error>> {
6054
.extract_policy(&signers_container, BuildSatisfaction::None, &secp)?
6155
.expect("We expect a policy");
6256

63-
log::info!("Derived Policy for the descriptor {:#?}", policy);
57+
println!("Derived Policy for the descriptor {:#?}", policy);
6458

6559
Ok(())
6660
}

crates/bdk/src/descriptor/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,11 +488,6 @@ impl DescriptorMeta for ExtendedDescriptor {
488488
) {
489489
Some(derive_path)
490490
} else {
491-
log::debug!(
492-
"Key `{}` derived with {} yields an unexpected key",
493-
root_fingerprint,
494-
derive_path
495-
);
496491
None
497492
}
498493
});

crates/bdk/src/descriptor/policy.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ use miniscript::{
5858
Descriptor, Miniscript, Satisfier, ScriptContext, SigType, Terminal, ToPublicKey,
5959
};
6060

61-
#[allow(unused_imports)]
62-
use log::{debug, error, info, trace};
63-
6461
use crate::descriptor::ExtractPolicy;
6562
use crate::keys::ExtScriptContext;
6663
use crate::wallet::signer::{SignerId, SignersContainer};

crates/bdk/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub extern crate alloc;
1919
pub extern crate bitcoin;
2020
#[cfg(feature = "hardware-signer")]
2121
pub extern crate hwi;
22-
extern crate log;
2322
pub extern crate miniscript;
2423
extern crate serde;
2524
extern crate serde_json;

crates/bdk/src/wallet/coin_selection.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,6 @@ impl CoinSelectionAlgorithm for LargestFirstCoinSelection {
254254
target_amount: u64,
255255
drain_script: &Script,
256256
) -> Result<CoinSelectionResult, Error> {
257-
log::debug!(
258-
"target_amount = `{}`, fee_rate = `{:?}`",
259-
target_amount,
260-
fee_rate
261-
);
262-
263257
// We put the "required UTXOs" first and make sure the optional UTXOs are sorted,
264258
// initially smallest to largest, before being reversed with `.rev()`.
265259
let utxos = {
@@ -352,13 +346,6 @@ fn select_sorted_utxos(
352346
(TXIN_BASE_WEIGHT + weighted_utxo.satisfaction_weight) as u64,
353347
));
354348
**selected_amount += weighted_utxo.utxo.txout().value;
355-
356-
log::debug!(
357-
"Selected {}, updated fee_amount = `{}`",
358-
weighted_utxo.utxo.outpoint(),
359-
fee_amount
360-
);
361-
362349
Some(weighted_utxo.utxo)
363350
} else {
364351
None

crates/bdk/src/wallet/mod.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ use descriptor::error::Error as DescriptorError;
4242
use miniscript::psbt::{PsbtExt, PsbtInputExt, PsbtInputSatisfier};
4343

4444
use bdk_chain::tx_graph::CalculateFeeError;
45-
#[allow(unused_imports)]
46-
use log::{debug, error, info, trace};
4745

4846
pub mod coin_selection;
4947
pub mod export;
@@ -1231,7 +1229,6 @@ impl<D> Wallet<D> {
12311229

12321230
let requirements =
12331231
external_requirements.merge(&internal_requirements.unwrap_or_default())?;
1234-
debug!("Policy requirements: {:?}", requirements);
12351232

12361233
let version = match params.version {
12371234
Some(tx_builder::Version(0)) => return Err(CreateTxError::Version0),
@@ -1828,11 +1825,6 @@ impl<D> Wallet<D> {
18281825
.assume_height
18291826
.unwrap_or_else(|| self.chain.tip().height());
18301827

1831-
debug!(
1832-
"Input #{} - {}, using `confirmation_height` = {:?}, `current_height` = {:?}",
1833-
n, input.previous_output, confirmation_height, current_height
1834-
);
1835-
18361828
// - Try to derive the descriptor by looking at the txout. If it's in our database, we
18371829
// know exactly which `keychain` to use, and which derivation index it is
18381830
// - If that fails, try to derive it by looking at the psbt input: the complete logic
@@ -1875,10 +1867,7 @@ impl<D> Wallet<D> {
18751867
psbt_input.partial_sigs.clear();
18761868
}
18771869
}
1878-
Err(e) => {
1879-
debug!("satisfy error {:?} for input {}", e, n);
1880-
finished = false
1881-
}
1870+
Err(_) => finished = false,
18821871
}
18831872
}
18841873
None => finished = false,
@@ -2207,11 +2196,6 @@ impl<D> Wallet<D> {
22072196
if let Some(&(keychain, child)) =
22082197
self.indexed_graph.index.index_of_spk(&out.script_pubkey)
22092198
{
2210-
debug!(
2211-
"Found descriptor for input #{} {:?}/{}",
2212-
index, keychain, child
2213-
);
2214-
22152199
let desc = self.get_descriptor_for_keychain(keychain);
22162200
let desc = desc
22172201
.at_derivation_index(child)

0 commit comments

Comments
 (0)