diff --git a/Cargo.toml b/Cargo.toml index 1c29bbaf5..1256dd2cc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,3 +21,7 @@ members = [ [workspace.package] authors = ["Bitcoin Dev Kit Developers"] + +[workspace.lints.clippy] +print_stdout = "deny" +print_stderr = "deny" diff --git a/clippy.toml b/clippy.toml index e3b99604d..69478ceab 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1 +1 @@ -msrv="1.63.0" \ No newline at end of file +msrv="1.63.0" diff --git a/crates/bitcoind_rpc/Cargo.toml b/crates/bitcoind_rpc/Cargo.toml index bee58efa1..09a76b6fa 100644 --- a/crates/bitcoind_rpc/Cargo.toml +++ b/crates/bitcoind_rpc/Cargo.toml @@ -12,6 +12,9 @@ readme = "README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lints] +workspace = true + [dependencies] bitcoin = { version = "0.32.0", default-features = false } bitcoincore-rpc = { version = "0.19.0" } diff --git a/crates/bitcoind_rpc/tests/test_emitter.rs b/crates/bitcoind_rpc/tests/test_emitter.rs index 3a5c67055..8c41efc03 100644 --- a/crates/bitcoind_rpc/tests/test_emitter.rs +++ b/crates/bitcoind_rpc/tests/test_emitter.rs @@ -36,7 +36,7 @@ pub fn test_sync_local_chain() -> anyhow::Result<()> { }; // See if the emitter outputs the right blocks. - println!("first sync:"); + while let Some(emission) = emitter.next_block()? { let height = emission.block_height(); let hash = emission.block_hash(); @@ -76,7 +76,7 @@ pub fn test_sync_local_chain() -> anyhow::Result<()> { .collect::>(); // See if the emitter outputs the right blocks. - println!("after reorg:"); + let mut exp_height = exp_hashes.len() - reorged_blocks.len(); while let Some(emission) = emitter.next_block()? { let height = emission.block_height(); @@ -132,7 +132,6 @@ pub fn test_sync_local_chain() -> anyhow::Result<()> { fn test_into_tx_graph() -> anyhow::Result<()> { let env = TestEnv::new()?; - println!("getting new addresses!"); let addr_0 = env .rpc_client() .get_new_address(None, None)? @@ -145,11 +144,8 @@ fn test_into_tx_graph() -> anyhow::Result<()> { .rpc_client() .get_new_address(None, None)? .assume_checked(); - println!("got new addresses!"); - println!("mining block!"); env.mine_blocks(101, None)?; - println!("mined blocks!"); let (mut chain, _) = LocalChain::from_genesis_hash(env.rpc_client().get_block_hash(0)?); let mut indexed_tx_graph = IndexedTxGraph::::new({ @@ -609,7 +605,6 @@ fn mempool_during_reorg() -> anyhow::Result<()> { // perform reorgs at different heights, these reorgs will not confirm transactions in the // mempool for reorg_count in 1..TIP_DIFF { - println!("REORG COUNT: {}", reorg_count); env.reorg_empty_blocks(reorg_count)?; // This is a map of mempool txids to tip height where the tx was introduced to the mempool @@ -627,7 +622,6 @@ fn mempool_during_reorg() -> anyhow::Result<()> { // `next_header` emits the replacement block of the reorg if let Some(emission) = emitter.next_header()? { let height = emission.block_height(); - println!("\t- replacement height: {}", height); // the mempool emission (that follows the first block emission after reorg) should only // include mempool txs introduced at reorg height or greater diff --git a/crates/chain/Cargo.toml b/crates/chain/Cargo.toml index 7261bdfa2..0651e7180 100644 --- a/crates/chain/Cargo.toml +++ b/crates/chain/Cargo.toml @@ -12,6 +12,9 @@ readme = "README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lints] +workspace = true + [dependencies] bitcoin = { version = "0.32.0", default-features = false } serde = { version = "1", optional = true, features = ["derive", "rc"] } diff --git a/crates/chain/tests/test_local_chain.rs b/crates/chain/tests/test_local_chain.rs index 6819e3da1..29686564d 100644 --- a/crates/chain/tests/test_local_chain.rs +++ b/crates/chain/tests/test_local_chain.rs @@ -34,7 +34,6 @@ enum ExpectedResult<'a> { impl<'a> TestLocalChain<'a> { fn run(mut self) { - println!("[TestLocalChain] test: {}", self.name); let got_changeset = match self.chain.apply_update(self.update) { Ok(changeset) => changeset, Err(got_err) => { @@ -255,7 +254,7 @@ fn update_local_chain() { (4, None) ], init_changeset: &[ - (0, Some(h!("_"))), + (0, Some(h!("_"))), (1, Some(h!("B'"))), (2, Some(h!("C'"))), (3, Some(h!("D"))), @@ -437,8 +436,6 @@ fn local_chain_disconnect_from() { ]; for (i, t) in test_cases.into_iter().enumerate() { - println!("Case {}: {}", i, t.name); - let mut chain = t.original; let result = chain.disconnect_from(t.disconnect_from.into()); assert_eq!( @@ -491,7 +488,6 @@ fn checkpoint_from_block_ids() { ]; for (i, t) in test_cases.into_iter().enumerate() { - println!("running test case {}: '{}'", i, t.name); let result = CheckPoint::from_block_ids( t.blocks .iter() @@ -583,6 +579,7 @@ fn checkpoint_query() { fn checkpoint_insert() { struct TestCase<'a> { /// The name of the test. + #[allow(dead_code)] name: &'a str, /// The original checkpoint chain to call [`CheckPoint::insert`] on. chain: &'a [(u32, BlockHash)], @@ -629,9 +626,7 @@ fn checkpoint_insert() { core::iter::once((0, h!("_"))).map(BlockId::from) } - for (i, t) in test_cases.into_iter().enumerate() { - println!("Running [{}] '{}'", i, t.name); - + for t in test_cases.into_iter() { let chain = CheckPoint::from_block_ids( genesis_block().chain(t.chain.iter().copied().map(BlockId::from)), ) @@ -792,7 +787,6 @@ fn local_chain_apply_header_connected_to() { ]; for (i, t) in test_cases.into_iter().enumerate() { - println!("running test case {}: '{}'", i, t.name); let mut chain = t.chain; let result = chain.apply_header_connected_to(&t.header, t.height, t.connected_to); let exp_result = t diff --git a/crates/electrum/Cargo.toml b/crates/electrum/Cargo.toml index eff11daac..489d35a5c 100644 --- a/crates/electrum/Cargo.toml +++ b/crates/electrum/Cargo.toml @@ -9,6 +9,9 @@ description = "Fetch data from electrum in the form BDK accepts" license = "MIT OR Apache-2.0" readme = "README.md" +[lints] +workspace = true + [dependencies] bdk_chain = { path = "../chain", version = "0.17.0" } electrum-client = { version = "0.21", features = ["proxy"], default-features = false } diff --git a/crates/esplora/Cargo.toml b/crates/esplora/Cargo.toml index 9148a0f86..422cf99fb 100644 --- a/crates/esplora/Cargo.toml +++ b/crates/esplora/Cargo.toml @@ -11,6 +11,9 @@ readme = "README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lints] +workspace = true + [dependencies] bdk_chain = { path = "../chain", version = "0.17.0", default-features = false } esplora-client = { version = "0.9.0", default-features = false } diff --git a/crates/esplora/src/async_ext.rs b/crates/esplora/src/async_ext.rs index 066b91e17..c236d4908 100644 --- a/crates/esplora/src/async_ext.rs +++ b/crates/esplora/src/async_ext.rs @@ -490,6 +490,7 @@ mod test { #[tokio::test] pub async fn test_finalize_chain_update() -> anyhow::Result<()> { struct TestCase<'a> { + #[allow(dead_code)] name: &'a str, /// Initial blockchain height to start the env with. initial_env_height: u32, @@ -526,9 +527,7 @@ mod test { }, ]; - for (i, t) in test_cases.into_iter().enumerate() { - println!("[{}] running test case: {}", i, t.name); - + for t in test_cases.into_iter() { let env = TestEnv::new()?; let base_url = format!("http://{}", &env.electrsd.esplora_url.clone().unwrap()); let client = Builder::new(base_url.as_str()).build_async()?; @@ -571,7 +570,6 @@ mod test { chain.apply_update(update)?; chain }; - println!("local chain height: {}", local_chain.tip().height()); // extend env chain if let Some(to_mine) = t @@ -611,10 +609,6 @@ mod test { // apply update let mut updated_local_chain = local_chain.clone(); updated_local_chain.apply_update(update)?; - println!( - "updated local chain height: {}", - updated_local_chain.tip().height() - ); assert!( { diff --git a/crates/esplora/src/blocking_ext.rs b/crates/esplora/src/blocking_ext.rs index 6e3e25afe..0806995f1 100644 --- a/crates/esplora/src/blocking_ext.rs +++ b/crates/esplora/src/blocking_ext.rs @@ -490,6 +490,7 @@ mod test { #[test] pub fn test_finalize_chain_update() -> anyhow::Result<()> { struct TestCase<'a> { + #[allow(dead_code)] name: &'a str, /// Initial blockchain height to start the env with. initial_env_height: u32, @@ -526,9 +527,7 @@ mod test { }, ]; - for (i, t) in test_cases.into_iter().enumerate() { - println!("[{}] running test case: {}", i, t.name); - + for t in test_cases.into_iter() { let env = TestEnv::new()?; let base_url = format!("http://{}", &env.electrsd.esplora_url.clone().unwrap()); let client = Builder::new(base_url.as_str()).build_blocking(); @@ -570,7 +569,6 @@ mod test { chain.apply_update(update)?; chain }; - println!("local chain height: {}", local_chain.tip().height()); // extend env chain if let Some(to_mine) = t @@ -609,10 +607,6 @@ mod test { // apply update let mut updated_local_chain = local_chain.clone(); updated_local_chain.apply_update(update)?; - println!( - "updated local chain height: {}", - updated_local_chain.tip().height() - ); assert!( { @@ -773,7 +767,6 @@ mod test { ]; for (i, t) in test_cases.into_iter().enumerate() { - println!("Case {}: {}", i, t.name); let mut chain = t.chain; let mock_anchors = t diff --git a/crates/file_store/Cargo.toml b/crates/file_store/Cargo.toml index 3e4c11d0c..50f86c5b8 100644 --- a/crates/file_store/Cargo.toml +++ b/crates/file_store/Cargo.toml @@ -10,6 +10,9 @@ keywords = ["bitcoin", "persist", "persistence", "bdk", "file"] authors = ["Bitcoin Dev Kit Developers"] readme = "README.md" +[lints] +workspace = true + [dependencies] bdk_chain = { path = "../chain", version = "0.17.0", features = [ "serde", "miniscript" ] } bincode = { version = "1" } diff --git a/crates/file_store/src/store.rs b/crates/file_store/src/store.rs index d1bd3c40c..62c3d91b6 100644 --- a/crates/file_store/src/store.rs +++ b/crates/file_store/src/store.rs @@ -340,7 +340,6 @@ mod test { for short_write_len in 1..last_changeset_bytes.len() - 1 { let file_path = temp_dir.path().join(format!("{}.dat", short_write_len)); - println!("Test file: {:?}", file_path); // simulate creating a file, writing data where the last write is incomplete { @@ -406,7 +405,6 @@ mod test { for read_count in 0..changesets.len() { let file_path = temp_dir.path().join(format!("{}.dat", read_count)); - println!("Test file: {:?}", file_path); // First, we create the file with all the changesets! let mut db = Store::::create_new(&TEST_MAGIC_BYTES, &file_path).unwrap(); diff --git a/crates/hwi/Cargo.toml b/crates/hwi/Cargo.toml index b4ae39fe9..154833f1e 100644 --- a/crates/hwi/Cargo.toml +++ b/crates/hwi/Cargo.toml @@ -8,6 +8,9 @@ description = "Utilities to use bdk with hardware wallets" license = "MIT OR Apache-2.0" readme = "README.md" +[lints] +workspace = true + [dependencies] bdk_wallet = { path = "../wallet", version = "1.0.0-beta.1" } hwi = { version = "0.9.0", features = [ "miniscript"] } diff --git a/crates/testenv/Cargo.toml b/crates/testenv/Cargo.toml index 2d9c26caa..48fa1f6b0 100644 --- a/crates/testenv/Cargo.toml +++ b/crates/testenv/Cargo.toml @@ -12,6 +12,9 @@ readme = "README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[lints] +workspace = true + [dependencies] bdk_chain = { path = "../chain", version = "0.17", default-features = false } electrsd = { version = "0.28.0", features = ["bitcoind_25_0", "esplora_a33e97e1", "legacy"] } diff --git a/crates/wallet/Cargo.toml b/crates/wallet/Cargo.toml index 44314a968..aa3531709 100644 --- a/crates/wallet/Cargo.toml +++ b/crates/wallet/Cargo.toml @@ -12,6 +12,9 @@ authors = ["Bitcoin Dev Kit Developers"] edition = "2021" rust-version = "1.63" +[lints] +workspace = true + [dependencies] rand_core = { version = "0.6.0" } miniscript = { version = "12.0.0", features = ["serde"], default-features = false } diff --git a/crates/wallet/examples/compiler.rs b/crates/wallet/examples/compiler.rs index 72bed012e..d0922fa4e 100644 --- a/crates/wallet/examples/compiler.rs +++ b/crates/wallet/examples/compiler.rs @@ -31,6 +31,7 @@ use bdk_wallet::{KeychainKind, Wallet}; /// /// This example demonstrates the interaction between a bdk wallet and miniscript policy. +#[allow(clippy::print_stdout)] fn main() -> Result<(), Box> { // We start with a miniscript policy string let policy_str = "or( diff --git a/crates/wallet/examples/mnemonic_to_descriptors.rs b/crates/wallet/examples/mnemonic_to_descriptors.rs index 76c53cf29..19154c2d7 100644 --- a/crates/wallet/examples/mnemonic_to_descriptors.rs +++ b/crates/wallet/examples/mnemonic_to_descriptors.rs @@ -19,6 +19,7 @@ use std::str::FromStr; /// This example demonstrates how to generate a mnemonic phrase /// using BDK and use that to generate a descriptor string. +#[allow(clippy::print_stdout)] fn main() -> Result<(), anyhow::Error> { let secp = Secp256k1::new(); diff --git a/crates/wallet/examples/policy.rs b/crates/wallet/examples/policy.rs index 6e0c82690..e64d47b53 100644 --- a/crates/wallet/examples/policy.rs +++ b/crates/wallet/examples/policy.rs @@ -26,6 +26,7 @@ use bdk_wallet::signer::SignersContainer; /// This example demos a Policy output for a 2of2 multisig between between 2 parties, where the wallet holds /// one of the Extend Private key. +#[allow(clippy::print_stdout)] fn main() -> Result<(), Box> { let secp = bitcoin::secp256k1::Secp256k1::new(); diff --git a/crates/wallet/src/wallet/coin_selection.rs b/crates/wallet/src/wallet/coin_selection.rs index 4cd900378..8dc36b198 100644 --- a/crates/wallet/src/wallet/coin_selection.rs +++ b/crates/wallet/src/wallet/coin_selection.rs @@ -1579,7 +1579,6 @@ mod test { ]; for (i, t) in test_cases.into_iter().enumerate() { - println!("Case {}: {}", i, t.name); let (required, optional) = filter_duplicates(to_utxo_vec(t.required), to_utxo_vec(t.optional)); assert_eq!(