diff --git a/Cargo-minimal.lock b/Cargo-minimal.lock index 4ec10eca..2b645c5d 100644 --- a/Cargo-minimal.lock +++ b/Cargo-minimal.lock @@ -393,6 +393,7 @@ dependencies = [ "bitcoin", "bitreq", "electrsd", + "esplora-types", "hex-conservative 0.2.2", "log", "native-tls", @@ -406,6 +407,14 @@ dependencies = [ "tokio", ] +[[package]] +name = "esplora-types" +version = "0.1.0" +dependencies = [ + "bitcoin", + "serde", +] + [[package]] name = "fastrand" version = "2.1.1" @@ -972,9 +981,9 @@ dependencies = [ [[package]] name = "spin" -version = "0.9.2" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "511254be0c5bcf062b019a6c89c01a664aa359ded62f78aa72c6fc137c0590e5" +checksum = "3763264f6b73151db08c50ff20d7d8a0b8796e021cdea7ceedad07b80155fa0e" [[package]] name = "subtle" diff --git a/Cargo-recent.lock b/Cargo-recent.lock index 1f060d39..187abd01 100644 --- a/Cargo-recent.lock +++ b/Cargo-recent.lock @@ -319,6 +319,7 @@ dependencies = [ "bitcoin", "bitreq", "electrsd", + "esplora-types", "hex-conservative", "log", "native-tls", @@ -332,6 +333,14 @@ dependencies = [ "tokio", ] +[[package]] +name = "esplora-types" +version = "0.1.0" +dependencies = [ + "bitcoin", + "serde", +] + [[package]] name = "fastrand" version = "2.4.1" diff --git a/Cargo.toml b/Cargo.toml index aef30fee..ba6b5b10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,94 +1,7 @@ -[package] -name = "esplora-client" -version = "0.13.0" -edition = "2021" -authors = [ - "Alekos Filini ", - "Bitcoin Dev Kit Developers" -] -license = "MIT OR Apache-2.0" -homepage = "https://github.com/bitcoindevkit/rust-esplora-client" -repository = "https://github.com/bitcoindevkit/rust-esplora-client" -documentation = "https://docs.rs/esplora-client/" -description = "Asynchronous and blocking clients and types for interacting with Esplora servers over HTTP" -keywords = ["bitcoin", "esplora"] -readme = "README.md" -rust-version = "1.75.0" # MSRV +[workspace] +members = ["esplora-client", "esplora-types"] +resolver = "2" -[lib] -name = "esplora_client" -path = "src/lib.rs" - -[dependencies] -serde = { version = "1.0.194", features = ["derive"] } -serde_json = { version = "1.0.117", features = ["std"], default-features = false } -bitcoin = { version = "0.32", features = ["serde", "std"], default-features = false } -hex = { version = "0.2.2", package = "hex-conservative" } -bitreq = { version = "0.3.7", optional = true } -# Default runtime when running async tests -tokio = { version = "1", features = ["time"], optional = true } - -[dev-dependencies] -tokio = { version = "1", features = ["full"] } -electrsd = { version = "0.40.0", default-features = false, features = ["legacy", "esplora_a33e97e1", "bitcoind_download", "bitcoind_29_0"] } -# These pins are needed for `Cargo-minimal.lock`: -tar = { version = "0.4.45" } # blame: electrsd v0.38.0 -> bitcoind -> tar -log = { version = "0.4.29" } # blame: electrsd v0.38.0 -> bitcoind -> corepc_client -openssl-sys = { version = "0.9.114" } # blame: bitreq v0.3.5 -> native-tls -> openssl -openssl = { version = "0.10.78" } # blame: match `openssl-sys` -native-tls = { version = "0.2.11" } # blame: bitreq v0.3.5 -> native-tls -tempfile = { version = "=3.15.0" } # blame: tempfile >=v3.16 requires getrandom >=v0.3 -security-framework = { version = "=2.11.1" } # blame: rustls-native-certs 0.8.3 → security-framework 3.x (edition2024) - -[features] -default = ["blocking", "blocking-https", "async", "async-https", "tokio"] - -tokio = ["dep:tokio"] -async = ["bitreq/async", "bitreq/proxy", "bitreq/json-using-serde", "tokio?/time"] -async-https = ["async", "bitreq/async-https"] -async-https-native = ["async", "bitreq/async-https-native-tls"] -async-https-rustls = ["async", "bitreq/async-https-rustls"] -async-https-rustls-probe = ["async", "bitreq/async-https-rustls-probe"] - -blocking = ["bitreq/proxy", "bitreq/json-using-serde"] -blocking-https = ["blocking", "bitreq/https"] -blocking-https-native = ["blocking", "bitreq/https-native-tls"] -blocking-https-rustls = ["blocking", "bitreq/https-rustls"] -blocking-https-rustls-probe = ["blocking", "bitreq/https-rustls-probe"] - -[package.metadata.rbmt.toolchains] +[workspace.metadata.rbmt.toolchains] stable = "1.96.1" nightly = "nightly-2026-07-03" - -[package.metadata.docs.rs] -all-features = true -rustdoc-args = ["--cfg", "docsrs"] - -[package.metadata.rbmt.lint] -allowed_duplicates = [ - "getrandom", - "windows-sys", - "wit-bindgen", -] - -[package.metadata.rbmt.test] -# Don't test these features in isolation -exclude_features = [ - "tokio", - "async-https", - "async-https-native", - "async-https-rustls", - "async-https-rustls-probe", - "blocking-https", - "blocking-https-native", - "blocking-https-rustls", - "blocking-https-rustls-probe", -] -# Run tests using these exact feature sets -exact_features = [ - ["async", "blocking"], - ["async-https", "blocking-https", "tokio"], - ["async-https-native", "blocking-https-native", "tokio"], - ["async-https-rustls", "blocking-https-rustls", "tokio"], - ["async-https-rustls-probe", "blocking-https-rustls-probe", "tokio"], -] diff --git a/README.md b/README.md index 0c54476c..7e1e3858 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # rust-esplora-client

- - @@ -10,6 +8,17 @@ Asynchronous and blocking clients and types for interacting with Esplora servers over HTTP. +## Crates in this repository + +This is a Cargo workspace containing two crates: + +| Crate | Description | Badges | +|---|---|---| +| [`esplora-client`](./esplora-client) | Blocking and async HTTP clients for the Esplora API. | [![Crate Info](https://img.shields.io/crates/v/esplora-client.svg)](https://crates.io/crates/esplora-client) [![API Docs](https://img.shields.io/badge/docs.rs-esplora--client-blue)](https://docs.rs/esplora-client) | +| [`esplora-types`](./esplora-types) | The Esplora request/response types, with no HTTP client dependency. | [![Crate Info](https://img.shields.io/crates/v/esplora-types.svg)](https://crates.io/crates/esplora-types) [![API Docs](https://img.shields.io/badge/docs.rs-esplora--types-blue)](https://docs.rs/esplora-types) | + +`esplora-client` re-exports every `esplora-types` item under its own top level and under `esplora_client::api`, so existing code that imports from `esplora-client` alone continues to work unchanged. + ## Developing This project uses [`just`](https://github.com/casey/just) for command running, and @@ -45,7 +54,7 @@ Available recipes: ## Minimum Supported Rust Version -This library should compile with any combination of features on Rust 1.75.0. +Both crates in this workspace should compile with any combination of features on Rust 1.75.0. To build with the MSRV toolchain, copy `Cargo-minimal.lock` to `Cargo.lock`. diff --git a/CHANGELOG.md b/esplora-client/CHANGELOG.md similarity index 98% rename from CHANGELOG.md rename to esplora-client/CHANGELOG.md index 9e05a5a0..930442cd 100644 --- a/CHANGELOG.md +++ b/esplora-client/CHANGELOG.md @@ -6,6 +6,7 @@ ### Changed +* feat: split types into a new `esplora-types` crate, re-exported as `esplora_client::api` [#XXX] * chore!: remove deprecated `BlockSummary` and `get_block` [#225] ### Fixed diff --git a/esplora-client/Cargo.toml b/esplora-client/Cargo.toml new file mode 100644 index 00000000..a69983ba --- /dev/null +++ b/esplora-client/Cargo.toml @@ -0,0 +1,91 @@ +[package] +name = "esplora-client" +version = "0.13.0" +edition = "2021" +authors = [ + "Alekos Filini ", + "Bitcoin Dev Kit Developers" +] +license = "MIT OR Apache-2.0" +homepage = "https://github.com/bitcoindevkit/rust-esplora-client" +repository = "https://github.com/bitcoindevkit/rust-esplora-client" +documentation = "https://docs.rs/esplora-client/" +description = "Asynchronous and blocking clients and types for interacting with Esplora servers over HTTP" +keywords = ["bitcoin", "esplora"] +readme = "README.md" +rust-version = "1.75.0" # MSRV + +[lib] +name = "esplora_client" +path = "src/lib.rs" + +[dependencies] +esplora-types = { path = "../esplora-types", version = "0.1.0" } +serde = { version = "1.0.194", features = ["derive"] } +serde_json = { version = "1.0.117", features = ["std"], default-features = false } +bitcoin = { version = "0.32", features = ["serde", "std"], default-features = false } +hex = { version = "0.2.2", package = "hex-conservative" } +bitreq = { version = "0.3.7", optional = true } +# Default runtime when running async tests +tokio = { version = "1", features = ["time"], optional = true } + +[dev-dependencies] +tokio = { version = "1", features = ["full"] } +electrsd = { version = "0.40.0", default-features = false, features = ["legacy", "esplora_a33e97e1", "bitcoind_download", "bitcoind_29_0"] } +# These pins are needed for `Cargo-minimal.lock`: +tar = { version = "0.4.45" } # blame: electrsd v0.38.0 -> bitcoind -> tar +log = { version = "0.4.29" } # blame: electrsd v0.38.0 -> bitcoind -> corepc_client +openssl-sys = { version = "0.9.114" } # blame: bitreq v0.3.5 -> native-tls -> openssl +openssl = { version = "0.10.78" } # blame: match `openssl-sys` +native-tls = { version = "0.2.11" } # blame: bitreq v0.3.5 -> native-tls +tempfile = { version = "=3.15.0" } # blame: tempfile >=v3.16 requires getrandom >=v0.3 +security-framework = { version = "=2.11.1" } # blame: rustls-native-certs 0.8.3 → security-framework 3.x (edition2024) + +[features] +default = ["blocking", "blocking-https", "async", "async-https", "tokio"] + +tokio = ["dep:tokio"] +async = ["bitreq/async", "bitreq/proxy", "bitreq/json-using-serde", "tokio?/time"] +async-https = ["async", "bitreq/async-https"] +async-https-native = ["async", "bitreq/async-https-native-tls"] +async-https-rustls = ["async", "bitreq/async-https-rustls"] +async-https-rustls-probe = ["async", "bitreq/async-https-rustls-probe"] + +blocking = ["bitreq/proxy", "bitreq/json-using-serde"] +blocking-https = ["blocking", "bitreq/https"] +blocking-https-native = ["blocking", "bitreq/https-native-tls"] +blocking-https-rustls = ["blocking", "bitreq/https-rustls"] +blocking-https-rustls-probe = ["blocking", "bitreq/https-rustls-probe"] + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + +[package.metadata.rbmt.lint] +allowed_duplicates = [ + "getrandom", + "windows-sys", + "wit-bindgen", +] + +[package.metadata.rbmt.test] +# Don't test these features in isolation +exclude_features = [ + "tokio", + "async-https", + "async-https-native", + "async-https-rustls", + "async-https-rustls-probe", + "blocking-https", + "blocking-https-native", + "blocking-https-rustls", + "blocking-https-rustls-probe", +] +# Run tests using these exact feature sets +exact_features = [ + ["async", "blocking"], + ["async-https", "blocking-https", "tokio"], + ["async-https-native", "blocking-https-native", "tokio"], + ["async-https-rustls", "blocking-https-rustls", "tokio"], + ["async-https-rustls-probe", "blocking-https-rustls-probe", "tokio"], +] diff --git a/esplora-client/README.md b/esplora-client/README.md new file mode 100644 index 00000000..584d50d1 --- /dev/null +++ b/esplora-client/README.md @@ -0,0 +1,5 @@ +# Esplora Client + +Asynchronous and blocking clients for interacting with Esplora servers over HTTP. + +See [`esplora-types`](../esplora-types) if you only need the request/response types, with no HTTP client dependency. diff --git a/src/async.rs b/esplora-client/src/async.rs similarity index 100% rename from src/async.rs rename to esplora-client/src/async.rs diff --git a/src/blocking.rs b/esplora-client/src/blocking.rs similarity index 100% rename from src/blocking.rs rename to esplora-client/src/blocking.rs diff --git a/src/lib.rs b/esplora-client/src/lib.rs similarity index 99% rename from src/lib.rs rename to esplora-client/src/lib.rs index f1f8c008..fd523787 100644 --- a/src/lib.rs +++ b/esplora-client/src/lib.rs @@ -98,7 +98,7 @@ use std::time::Duration; #[cfg(feature = "async")] pub use r#async::Sleeper; -pub mod api; +pub use esplora_types as api; #[cfg(feature = "async")] pub mod r#async; #[cfg(feature = "blocking")] diff --git a/tests/address.rs b/esplora-client/tests/address.rs similarity index 100% rename from tests/address.rs rename to esplora-client/tests/address.rs diff --git a/tests/block.rs b/esplora-client/tests/block.rs similarity index 100% rename from tests/block.rs rename to esplora-client/tests/block.rs diff --git a/tests/mempool.rs b/esplora-client/tests/mempool.rs similarity index 100% rename from tests/mempool.rs rename to esplora-client/tests/mempool.rs diff --git a/tests/scripthash.rs b/esplora-client/tests/scripthash.rs similarity index 100% rename from tests/scripthash.rs rename to esplora-client/tests/scripthash.rs diff --git a/tests/testenv/mod.rs b/esplora-client/tests/testenv/mod.rs similarity index 100% rename from tests/testenv/mod.rs rename to esplora-client/tests/testenv/mod.rs diff --git a/tests/transaction.rs b/esplora-client/tests/transaction.rs similarity index 100% rename from tests/transaction.rs rename to esplora-client/tests/transaction.rs diff --git a/esplora-types/Cargo.toml b/esplora-types/Cargo.toml new file mode 100644 index 00000000..451e9185 --- /dev/null +++ b/esplora-types/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "esplora-types" +version = "0.1.0" +edition = "2021" +authors = [ + "Alekos Filini ", + "Bitcoin Dev Kit Developers" +] +license = "MIT OR Apache-2.0" +homepage = "https://github.com/bitcoindevkit/rust-esplora-client" +repository = "https://github.com/bitcoindevkit/rust-esplora-client" +documentation = "https://docs.rs/esplora-types/" +description = "Shared types for interacting with Esplora-compliant servers" +keywords = ["bitcoin", "esplora"] +readme = "README.md" +rust-version = "1.75.0" # MSRV + +[lib] +name = "esplora_types" + +[dependencies] +serde = { version = "1.0.194", features = ["derive"] } +bitcoin = { version = "0.32", features = ["serde"], default-features = false } + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] + diff --git a/esplora-types/README.md b/esplora-types/README.md new file mode 100644 index 00000000..97966179 --- /dev/null +++ b/esplora-types/README.md @@ -0,0 +1,8 @@ +# Esplora Types + +Shared, transport-agnostic types and deserializers for the +[Esplora API](https://github.com/Blockstream/esplora/blob/master/API.md). + +This crate has no HTTP client dependency. See +[`esplora-client`](../esplora-client) for a blocking and async HTTP client +built on these types. diff --git a/src/api.rs b/esplora-types/src/lib.rs similarity index 98% rename from src/api.rs rename to esplora-types/src/lib.rs index 474b4798..78fd3fe0 100644 --- a/src/api.rs +++ b/esplora-types/src/lib.rs @@ -1,9 +1,11 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 -//! # Esplora API +//! # Esplora Types //! -//! This module implements the types and deserializers -//! needed to interact with an Esplora-compliant server. +//! Shared, transport-agnostic types and deserializers for interacting with +//! an Esplora-compliant server. This crate has no HTTP client dependency; +//! see [`esplora-client`](https://docs.rs/esplora-client) for a blocking and +//! async HTTP client built on these types. //! //! Refer to the [Esplora API] specification for the complete API reference. //!