From 72b5f96b63ed7274734a59a83197a023fe1a2906 Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Wed, 15 Mar 2023 11:44:52 -0500 Subject: [PATCH] Better no-std support and bump `esplora-client` to 0.4 - Use `default-features = false` for `miniscript` and `bitcoin` - Introduce `std` & `no-std` features - Bump `esplora-client` to 0.4 --- crates/bdk/Cargo.toml | 12 ++++-------- crates/chain/Cargo.toml | 10 +++++----- crates/esplora/Cargo.toml | 2 +- crates/esplora/src/lib.rs | 2 ++ 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/crates/bdk/Cargo.toml b/crates/bdk/Cargo.toml index cc95099da1..41de077552 100644 --- a/crates/bdk/Cargo.toml +++ b/crates/bdk/Cargo.toml @@ -15,11 +15,11 @@ rust-version = "1.57" [dependencies] log = "^0.4" rand = "^0.8" -miniscript = { version = "9", features = ["serde"] } -bitcoin = { version = "0.29", features = ["serde", "base64", "rand"] } +miniscript = { version = "9", features = ["serde"], default-features = false } +bitcoin = { version = "0.29", features = ["serde", "base64", "rand"], default-features = false } serde = { version = "^1.0", features = ["derive"] } serde_json = { version = "^1.0" } -bdk_chain = { path = "../chain", version = "0.4.0", features = ["miniscript", "serde"] } +bdk_chain = { path = "../chain", version = "0.4.0", features = ["miniscript", "serde"], default-features = false } # Optional dependencies hwi = { version = "0.5", optional = true, features = [ "use-miniscript"] } @@ -29,17 +29,15 @@ bip39 = { version = "1.0.1", optional = true } getrandom = "0.2" js-sys = "0.3" - [features] default = ["std"] -std = [] +std = ["bitcoin/std", "miniscript/std", "bdk_chain/std"] compiler = ["miniscript/compiler"] all-keys = ["keys-bip39"] keys-bip39 = ["bip39"] hardware-signer = ["hwi"] test-hardware-signer = ["hardware-signer"] - # This feature is used to run `cargo check` in our CI targeting wasm. It's not recommended # for libraries to explicitly include the "getrandom/js" feature, so we only do it when # necessary for running our CI. See: https://docs.rs/getrandom/0.2.8/getrandom/#webassembly-support @@ -52,12 +50,10 @@ env_logger = "0.7" base64 = "^0.13" assert_matches = "1.5.0" - [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] - [[example]] name = "mnemonic_to_descriptors" path = "examples/mnemonic_to_descriptors.rs" diff --git a/crates/chain/Cargo.toml b/crates/chain/Cargo.toml index bb4786675c..0d8123ca78 100644 --- a/crates/chain/Cargo.toml +++ b/crates/chain/Cargo.toml @@ -13,18 +13,18 @@ readme = "README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bitcoin = { version = "0.29" } +bitcoin = { version = "0.29", default-features = false } serde_crate = { package = "serde", version = "1", optional = true, features = ["derive"] } # Use hashbrown as a feature flag to have HashSet and HashMap from it. # note version 0.13 breaks outs MSRV. -hashbrown = { version = "0.12", optional = true, features = ["serde"] } -miniscript = { version = "9.0.0", optional = true } +hashbrown = { version = "0.12", optional = true, features = ["serde"] } +miniscript = { version = "9.0.0", optional = true, default-features = false } [dev-dependencies] rand = "0.8" [features] -default = ["std", "miniscript"] -std = [] +default = ["std"] +std = ["bitcoin/std"] serde = ["serde_crate", "bitcoin/serde" ] diff --git a/crates/esplora/Cargo.toml b/crates/esplora/Cargo.toml index e55b6fa010..7375ca26e2 100644 --- a/crates/esplora/Cargo.toml +++ b/crates/esplora/Cargo.toml @@ -13,7 +13,7 @@ readme = "README.md" [dependencies] bdk_chain = { path = "../chain", version = "0.4.0", features = ["serde", "miniscript"] } -esplora-client = { version = "0.3", default-features = false } +esplora-client = { version = "0.4", default-features = false } async-trait = { version = "0.1.66", optional = true } futures = { version = "0.3.26", optional = true } diff --git a/crates/esplora/src/lib.rs b/crates/esplora/src/lib.rs index 8398fcb354..e6eedf5e2e 100644 --- a/crates/esplora/src/lib.rs +++ b/crates/esplora/src/lib.rs @@ -14,6 +14,8 @@ mod async_ext; #[cfg(feature = "async")] pub use async_ext::*; +// this is to avoid warnings when no feature flags are enabled +#[allow(dead_code)] pub(crate) fn map_confirmation_time( tx_status: &TxStatus, height_at_start: u32,