From 6098528db896b9912c337f7f0c3ba1510291e173 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 27 Oct 2025 10:35:04 +1100 Subject: [PATCH 1/5] bitreq: Rename MINREQ_TIMEOUT to BITREQ_TIMEOUT Stale name since we renamed the crate to `bitreq`. Fix a few instances of `s/minreq/bitreq` missed when forking. --- bitreq/src/connection.rs | 4 ++-- bitreq/src/lib.rs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bitreq/src/connection.rs b/bitreq/src/connection.rs index 0a72066d..1595e2f6 100644 --- a/bitreq/src/connection.rs +++ b/bitreq/src/connection.rs @@ -87,7 +87,7 @@ pub struct AsyncConnection { impl AsyncConnection { /// Creates a new `AsyncConnection`. pub(crate) fn new(request: ParsedRequest) -> AsyncConnection { - let timeout = request.config.timeout.or_else(|| match env::var("MINREQ_TIMEOUT") { + let timeout = request.config.timeout.or_else(|| match env::var("BITREQ_TIMEOUT") { Ok(t) => t.parse::().ok(), Err(_) => None, }); @@ -128,7 +128,7 @@ impl Connection { /// Creates a new `Connection`. See [Request] and [ParsedRequest] /// for specifics about *what* is being sent. pub(crate) fn new(request: ParsedRequest) -> Connection { - let timeout = request.config.timeout.or_else(|| match env::var("MINREQ_TIMEOUT") { + let timeout = request.config.timeout.or_else(|| match env::var("BITREQ_TIMEOUT") { Ok(t) => t.parse::().ok(), Err(_) => None, }); diff --git a/bitreq/src/lib.rs b/bitreq/src/lib.rs index eda3bbe7..9fc23abd 100644 --- a/bitreq/src/lib.rs +++ b/bitreq/src/lib.rs @@ -207,16 +207,16 @@ //! ```text,ignore //! bitreq::get("/").with_timeout(8).send(); //! ``` -//! - Set the environment variable `MINREQ_TIMEOUT` to the desired +//! - Set the environment variable `BITREQ_TIMEOUT` to the desired //! amount of seconds until timeout. Ie. if you have a program called //! `foo` that uses bitreq, and you want all the requests made by that //! program to timeout in 8 seconds, you launch the program like so: //! ```text,ignore -//! $ MINREQ_TIMEOUT=8 ./foo +//! $ BITREQ_TIMEOUT=8 ./foo //! ``` //! Or add the following somewhere before the requests in the code. //! ``` -//! std::env::set_var("MINREQ_TIMEOUT", "8"); +//! std::env::set_var("BITREQ_TIMEOUT", "8"); //! ``` //! If the timeout is set with `with_timeout`, the environment //! variable will be ignored. From 5b8b8cc77c55fc1b972a3e2f384ee6b87de9a99d Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 31 Oct 2025 08:20:38 +1100 Subject: [PATCH 2/5] bitreq: Fix stale crate docs heading Missed during crate rename. --- bitreq/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitreq/src/lib.rs b/bitreq/src/lib.rs index 9fc23abd..afa718de 100644 --- a/bitreq/src/lib.rs +++ b/bitreq/src/lib.rs @@ -1,4 +1,4 @@ -//! # Minreq +//! # Bitreq //! //! Simple, minimal-dependency HTTP client. The library has a very //! minimal API, so you'll probably know everything you need to after From fa402e95ef916750ce92242c89c83364f1d672c2 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Tue, 4 Nov 2025 18:49:27 +1100 Subject: [PATCH 3/5] Remove mention of minreq from rustdoc --- client/src/client_sync/v17/hidden.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/client_sync/v17/hidden.rs b/client/src/client_sync/v17/hidden.rs index decb5cc9..05e305da 100644 --- a/client/src/client_sync/v17/hidden.rs +++ b/client/src/client_sync/v17/hidden.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `waitforblock`. #[macro_export] From 1998fed4fdb254dcd5d077f806bd1e10627a8b07 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Tue, 4 Nov 2025 18:50:33 +1100 Subject: [PATCH 4/5] Fix stale fuzz target name Should have been done during the minreq -> bitreq rename. --- .github/workflows/cron-daily-fuzz.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cron-daily-fuzz.yml b/.github/workflows/cron-daily-fuzz.yml index 6343f5e2..ca6569f0 100644 --- a/.github/workflows/cron-daily-fuzz.yml +++ b/.github/workflows/cron-daily-fuzz.yml @@ -18,7 +18,7 @@ jobs: # We only get 20 jobs at a time, we probably don't want to go # over that limit with fuzzing because of the hour run time. fuzz_target: [ - minreq_http, + bitreq_http, simple_http, ] steps: From 4ef980d40dca8a6b39dff50fb7762affd74b4060 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 27 Oct 2025 10:25:28 +1100 Subject: [PATCH 5/5] Depend on bitreq We just forked `minreq` into this repository to create an HTTP crate that is specifically designed to be used by Bitcoin projects. As such we called it `bitreq`. Depend on the local `bitreq` crate instead of `minreq`. Done directly in `node` and `jsonrpc`. Indirectly in `client`, including rename of a million macros that have `minreq` in the name. --- Cargo-minimal.lock | 19 +------ Cargo-recent.lock | 19 +------ client/Cargo.toml | 2 +- client/src/client_sync/mod.rs | 8 +-- client/src/client_sync/v17/blockchain.rs | 2 +- client/src/client_sync/v17/control.rs | 2 +- client/src/client_sync/v17/generating.rs | 2 +- client/src/client_sync/v17/mining.rs | 2 +- client/src/client_sync/v17/mod.rs | 2 +- client/src/client_sync/v17/network.rs | 2 +- .../src/client_sync/v17/raw_transactions.rs | 2 +- client/src/client_sync/v17/util.rs | 2 +- client/src/client_sync/v17/wallet.rs | 2 +- client/src/client_sync/v18/control.rs | 2 +- client/src/client_sync/v18/mining.rs | 2 +- client/src/client_sync/v18/mod.rs | 2 +- client/src/client_sync/v18/network.rs | 2 +- .../src/client_sync/v18/raw_transactions.rs | 2 +- client/src/client_sync/v18/util.rs | 2 +- client/src/client_sync/v18/wallet.rs | 2 +- client/src/client_sync/v19/blockchain.rs | 2 +- client/src/client_sync/v19/mod.rs | 2 +- client/src/client_sync/v19/wallet.rs | 2 +- client/src/client_sync/v20/generating.rs | 2 +- client/src/client_sync/v20/mod.rs | 2 +- client/src/client_sync/v21/generating.rs | 2 +- client/src/client_sync/v21/hidden.rs | 2 +- client/src/client_sync/v21/mod.rs | 2 +- client/src/client_sync/v21/util.rs | 2 +- client/src/client_sync/v21/wallet.rs | 2 +- client/src/client_sync/v22/mod.rs | 2 +- client/src/client_sync/v22/signer.rs | 2 +- client/src/client_sync/v22/wallet.rs | 2 +- client/src/client_sync/v23/blockchain.rs | 2 +- client/src/client_sync/v23/mod.rs | 2 +- client/src/client_sync/v23/wallet.rs | 2 +- client/src/client_sync/v24/blockchain.rs | 2 +- client/src/client_sync/v24/mod.rs | 2 +- client/src/client_sync/v24/wallet.rs | 2 +- client/src/client_sync/v25/blockchain.rs | 2 +- client/src/client_sync/v25/generating.rs | 2 +- client/src/client_sync/v25/mod.rs | 2 +- client/src/client_sync/v26/blockchain.rs | 2 +- client/src/client_sync/v26/mining.rs | 2 +- client/src/client_sync/v26/mod.rs | 2 +- client/src/client_sync/v26/network.rs | 2 +- .../src/client_sync/v26/raw_transactions.rs | 2 +- client/src/client_sync/v27/mod.rs | 2 +- client/src/client_sync/v28/mod.rs | 2 +- .../src/client_sync/v28/raw_transactions.rs | 2 +- client/src/client_sync/v28/wallet.rs | 2 +- client/src/client_sync/v29/blockchain.rs | 2 +- client/src/client_sync/v29/mod.rs | 2 +- client/src/client_sync/v29/util.rs | 2 +- client/src/client_sync/v30/mod.rs | 2 +- fuzz/Cargo.toml | 6 +- .../{minreq_http.rs => bitreq_http.rs} | 4 +- fuzz/generate-files.sh | 2 +- jsonrpc/Cargo.toml | 6 +- jsonrpc/contrib/test_vars.sh | 2 +- .../http/{minreq_http.rs => bitreq_http.rs} | 56 +++++++++---------- jsonrpc/src/http/mod.rs | 4 +- jsonrpc/src/lib.rs | 10 ++-- node/Cargo.toml | 4 +- node/build.rs | 2 +- 65 files changed, 108 insertions(+), 138 deletions(-) rename fuzz/fuzz_targets/{minreq_http.rs => bitreq_http.rs} (92%) rename jsonrpc/src/http/{minreq_http.rs => bitreq_http.rs} (84%) diff --git a/Cargo-minimal.lock b/Cargo-minimal.lock index b6d159d1..738b88f2 100644 --- a/Cargo-minimal.lock +++ b/Cargo-minimal.lock @@ -279,11 +279,11 @@ version = "0.10.0" dependencies = [ "anyhow", "bitcoin_hashes", + "bitreq", "corepc-client", "env_logger", "flate2", "log", - "minreq", "serde_json", "tar", "tempfile", @@ -451,7 +451,7 @@ name = "jsonrpc" version = "0.18.0" dependencies = [ "base64 0.22.1", - "minreq", + "bitreq", "serde", "serde_json", "socks", @@ -501,21 +501,6 @@ dependencies = [ "adler2", ] -[[package]] -name = "minreq" -version = "2.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fdef521c74c2884a4f3570bcdb6d2a77b3c533feb6b27ac2ae72673cc221c64" -dependencies = [ - "log", - "once_cell", - "rustls", - "rustls-webpki", - "serde", - "serde_json", - "webpki-roots", -] - [[package]] name = "mio" version = "1.0.2" diff --git a/Cargo-recent.lock b/Cargo-recent.lock index 53897d05..40b0947f 100644 --- a/Cargo-recent.lock +++ b/Cargo-recent.lock @@ -279,11 +279,11 @@ version = "0.10.0" dependencies = [ "anyhow", "bitcoin_hashes", + "bitreq", "corepc-client", "env_logger", "flate2", "log", - "minreq", "serde_json", "tar", "tempfile", @@ -456,7 +456,7 @@ name = "jsonrpc" version = "0.18.0" dependencies = [ "base64 0.22.1", - "minreq", + "bitreq", "serde", "serde_json", "socks", @@ -506,21 +506,6 @@ dependencies = [ "adler2", ] -[[package]] -name = "minreq" -version = "2.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da0c420feb01b9fb5061f8c8f452534361dd783756dcf38ec45191ce55e7a161" -dependencies = [ - "log", - "once_cell", - "rustls", - "rustls-webpki", - "serde", - "serde_json", - "webpki-roots", -] - [[package]] name = "mio" version = "1.1.0" diff --git a/client/Cargo.toml b/client/Cargo.toml index 69e78b27..08f9ec4a 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -27,6 +27,6 @@ serde = { version = "1.0.103", default-features = false, features = [ "derive", serde_json = { version = "1.0.117" } types = { package = "corepc-types", version = "0.10.0", path = "../types", default-features = false, features = ["std"] } -jsonrpc = { version = "0.18.0", path = "../jsonrpc", features = ["minreq_http"], optional = true } +jsonrpc = { version = "0.18.0", path = "../jsonrpc", features = ["bitreq_http"], optional = true } [dev-dependencies] diff --git a/client/src/client_sync/mod.rs b/client/src/client_sync/mod.rs index fc32d66b..bca9e954 100644 --- a/client/src/client_sync/mod.rs +++ b/client/src/client_sync/mod.rs @@ -55,9 +55,9 @@ impl Auth { } } -/// Defines a `jsonrpc::Client` using `minreq`. +/// Defines a `jsonrpc::Client` using `bitreq`. #[macro_export] -macro_rules! define_jsonrpc_minreq_client { +macro_rules! define_jsonrpc_bitreq_client { ($version:literal) => { use std::fmt; @@ -81,7 +81,7 @@ macro_rules! define_jsonrpc_minreq_client { impl Client { /// Creates a client to a bitcoind JSON-RPC server without authentication. pub fn new(url: &str) -> Self { - let transport = jsonrpc::http::minreq_http::Builder::new() + let transport = jsonrpc::http::bitreq_http::Builder::new() .url(url) .expect("jsonrpc v0.18, this function does not error") .timeout(std::time::Duration::from_secs(60)) @@ -98,7 +98,7 @@ macro_rules! define_jsonrpc_minreq_client { } let (user, pass) = auth.get_user_pass()?; - let transport = jsonrpc::http::minreq_http::Builder::new() + let transport = jsonrpc::http::bitreq_http::Builder::new() .url(url) .expect("jsonrpc v0.18, this function does not error") .timeout(std::time::Duration::from_secs(60)) diff --git a/client/src/client_sync/v17/blockchain.rs b/client/src/client_sync/v17/blockchain.rs index f0b037ca..810fa19b 100644 --- a/client/src/client_sync/v17/blockchain.rs +++ b/client/src/client_sync/v17/blockchain.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `getblockchaininfo`. #[macro_export] diff --git a/client/src/client_sync/v17/control.rs b/client/src/client_sync/v17/control.rs index b84bd7ce..ab50b2c8 100644 --- a/client/src/client_sync/v17/control.rs +++ b/client/src/client_sync/v17/control.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `getmemoryinfo`. #[macro_export] diff --git a/client/src/client_sync/v17/generating.rs b/client/src/client_sync/v17/generating.rs index c7e5f7b5..7f4bddb3 100644 --- a/client/src/client_sync/v17/generating.rs +++ b/client/src/client_sync/v17/generating.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `generatetoaddress`. #[macro_export] diff --git a/client/src/client_sync/v17/mining.rs b/client/src/client_sync/v17/mining.rs index bc777030..80f50138 100644 --- a/client/src/client_sync/v17/mining.rs +++ b/client/src/client_sync/v17/mining.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `getblocktemplate`. #[macro_export] diff --git a/client/src/client_sync/v17/mod.rs b/client/src/client_sync/v17/mod.rs index 26613dd8..7921840d 100644 --- a/client/src/client_sync/v17/mod.rs +++ b/client/src/client_sync/v17/mod.rs @@ -25,7 +25,7 @@ use serde::{Deserialize, Serialize, Serializer}; use crate::client_sync::into_json; use crate::types::v17::*; -crate::define_jsonrpc_minreq_client!("v17"); +crate::define_jsonrpc_bitreq_client!("v17"); crate::impl_client_check_expected_server_version!({ [170200] }); // == Blockchain == diff --git a/client/src/client_sync/v17/network.rs b/client/src/client_sync/v17/network.rs index 41645ff3..59edfe12 100644 --- a/client/src/client_sync/v17/network.rs +++ b/client/src/client_sync/v17/network.rs @@ -7,7 +7,7 @@ //! Specifically this is methods found under the `== Network ==` section of the //! API docs of Bitcoin Core `v0.17`. //! -//! See, or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See, or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `addnode`. #[macro_export] diff --git a/client/src/client_sync/v17/raw_transactions.rs b/client/src/client_sync/v17/raw_transactions.rs index c108e055..2a7425f4 100644 --- a/client/src/client_sync/v17/raw_transactions.rs +++ b/client/src/client_sync/v17/raw_transactions.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `combinepsbt`. #[macro_export] diff --git a/client/src/client_sync/v17/util.rs b/client/src/client_sync/v17/util.rs index a55c09a7..169aadf9 100644 --- a/client/src/client_sync/v17/util.rs +++ b/client/src/client_sync/v17/util.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `createmultisig`. #[macro_export] diff --git a/client/src/client_sync/v17/wallet.rs b/client/src/client_sync/v17/wallet.rs index 2ca38780..c1db0027 100644 --- a/client/src/client_sync/v17/wallet.rs +++ b/client/src/client_sync/v17/wallet.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `abandontransaction`. #[macro_export] diff --git a/client/src/client_sync/v18/control.rs b/client/src/client_sync/v18/control.rs index a42efc11..10e32674 100644 --- a/client/src/client_sync/v18/control.rs +++ b/client/src/client_sync/v18/control.rs @@ -5,7 +5,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `getrpcinfo`. #[macro_export] diff --git a/client/src/client_sync/v18/mining.rs b/client/src/client_sync/v18/mining.rs index 9d688e9e..b331a1ab 100644 --- a/client/src/client_sync/v18/mining.rs +++ b/client/src/client_sync/v18/mining.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `submitheader`. #[macro_export] diff --git a/client/src/client_sync/v18/mod.rs b/client/src/client_sync/v18/mod.rs index 572b03c7..73a4f048 100644 --- a/client/src/client_sync/v18/mod.rs +++ b/client/src/client_sync/v18/mod.rs @@ -29,7 +29,7 @@ pub use crate::client_sync::{ }; // This publicly re-exports `Client`. -crate::define_jsonrpc_minreq_client!("v18"); +crate::define_jsonrpc_bitreq_client!("v18"); crate::impl_client_check_expected_server_version!({ [180100] }); // == Blockchain == diff --git a/client/src/client_sync/v18/network.rs b/client/src/client_sync/v18/network.rs index 6e0049b4..2c3b5090 100644 --- a/client/src/client_sync/v18/network.rs +++ b/client/src/client_sync/v18/network.rs @@ -7,7 +7,7 @@ //! Specifically this is methods found under the `== Network ==` section of the //! API docs of Bitcoin Core `v0.18`. //! -//! See, or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See, or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `getnodeaddresses`. #[macro_export] diff --git a/client/src/client_sync/v18/raw_transactions.rs b/client/src/client_sync/v18/raw_transactions.rs index 5211495f..80bc7146 100644 --- a/client/src/client_sync/v18/raw_transactions.rs +++ b/client/src/client_sync/v18/raw_transactions.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `analyzepsbt`. #[macro_export] diff --git a/client/src/client_sync/v18/util.rs b/client/src/client_sync/v18/util.rs index 8fee92e0..594db166 100644 --- a/client/src/client_sync/v18/util.rs +++ b/client/src/client_sync/v18/util.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `deriveaddresses`. #[macro_export] diff --git a/client/src/client_sync/v18/wallet.rs b/client/src/client_sync/v18/wallet.rs index ee517385..e3f96a07 100644 --- a/client/src/client_sync/v18/wallet.rs +++ b/client/src/client_sync/v18/wallet.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `getreceivedbylabel`. #[macro_export] macro_rules! impl_client_v18__get_received_by_label { diff --git a/client/src/client_sync/v19/blockchain.rs b/client/src/client_sync/v19/blockchain.rs index 6eab4652..d82bc623 100644 --- a/client/src/client_sync/v19/blockchain.rs +++ b/client/src/client_sync/v19/blockchain.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `getblockfilter`. #[macro_export] diff --git a/client/src/client_sync/v19/mod.rs b/client/src/client_sync/v19/mod.rs index aa72f9bc..8bed0e35 100644 --- a/client/src/client_sync/v19/mod.rs +++ b/client/src/client_sync/v19/mod.rs @@ -24,7 +24,7 @@ pub use crate::client_sync::{ }, }; -crate::define_jsonrpc_minreq_client!("v19"); +crate::define_jsonrpc_bitreq_client!("v19"); crate::impl_client_check_expected_server_version!({ [190100] }); // == Blockchain == diff --git a/client/src/client_sync/v19/wallet.rs b/client/src/client_sync/v19/wallet.rs index c940124a..7c4920ff 100644 --- a/client/src/client_sync/v19/wallet.rs +++ b/client/src/client_sync/v19/wallet.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `getbalances`. #[macro_export] diff --git a/client/src/client_sync/v20/generating.rs b/client/src/client_sync/v20/generating.rs index a7ee33bb..6533f651 100644 --- a/client/src/client_sync/v20/generating.rs +++ b/client/src/client_sync/v20/generating.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `generatetodescriptor`. #[macro_export] diff --git a/client/src/client_sync/v20/mod.rs b/client/src/client_sync/v20/mod.rs index 83b4488f..067caf4c 100644 --- a/client/src/client_sync/v20/mod.rs +++ b/client/src/client_sync/v20/mod.rs @@ -23,7 +23,7 @@ pub use crate::client_sync::{ }, }; -crate::define_jsonrpc_minreq_client!("v20"); +crate::define_jsonrpc_bitreq_client!("v20"); crate::impl_client_check_expected_server_version!({ [200200] }); // == Blockchain == diff --git a/client/src/client_sync/v21/generating.rs b/client/src/client_sync/v21/generating.rs index 690e3eba..e9ec1b80 100644 --- a/client/src/client_sync/v21/generating.rs +++ b/client/src/client_sync/v21/generating.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `generateblock`. #[macro_export] diff --git a/client/src/client_sync/v21/hidden.rs b/client/src/client_sync/v21/hidden.rs index e7601632..8e6c9751 100644 --- a/client/src/client_sync/v21/hidden.rs +++ b/client/src/client_sync/v21/hidden.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `addpeeraddress`. #[macro_export] diff --git a/client/src/client_sync/v21/mod.rs b/client/src/client_sync/v21/mod.rs index 0a93c795..029a1c94 100644 --- a/client/src/client_sync/v21/mod.rs +++ b/client/src/client_sync/v21/mod.rs @@ -27,7 +27,7 @@ pub use crate::client_sync::{ }, }; -crate::define_jsonrpc_minreq_client!("v21"); +crate::define_jsonrpc_bitreq_client!("v21"); crate::impl_client_check_expected_server_version!({ [210200] }); // == Blockchain == diff --git a/client/src/client_sync/v21/util.rs b/client/src/client_sync/v21/util.rs index 2ed6864f..eca84998 100644 --- a/client/src/client_sync/v21/util.rs +++ b/client/src/client_sync/v21/util.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `getindexinfo`. #[macro_export] diff --git a/client/src/client_sync/v21/wallet.rs b/client/src/client_sync/v21/wallet.rs index 43f344b5..8fe15229 100644 --- a/client/src/client_sync/v21/wallet.rs +++ b/client/src/client_sync/v21/wallet.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `createwallet`. #[macro_export] diff --git a/client/src/client_sync/v22/mod.rs b/client/src/client_sync/v22/mod.rs index 59a52477..75658cb4 100644 --- a/client/src/client_sync/v22/mod.rs +++ b/client/src/client_sync/v22/mod.rs @@ -25,7 +25,7 @@ pub use crate::client_sync::{ v21::ImportDescriptorsRequest, }; -crate::define_jsonrpc_minreq_client!("v22"); +crate::define_jsonrpc_bitreq_client!("v22"); crate::impl_client_check_expected_server_version!({ [220100] }); // == Blockchain == diff --git a/client/src/client_sync/v22/signer.rs b/client/src/client_sync/v22/signer.rs index 384a2ea1..09551754 100644 --- a/client/src/client_sync/v22/signer.rs +++ b/client/src/client_sync/v22/signer.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `enumeratesigners` #[macro_export] diff --git a/client/src/client_sync/v22/wallet.rs b/client/src/client_sync/v22/wallet.rs index 92dffca5..2a6e4b00 100644 --- a/client/src/client_sync/v22/wallet.rs +++ b/client/src/client_sync/v22/wallet.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `listdescriptors`. #[macro_export] diff --git a/client/src/client_sync/v23/blockchain.rs b/client/src/client_sync/v23/blockchain.rs index 4c33a3f9..ec6194b2 100644 --- a/client/src/client_sync/v23/blockchain.rs +++ b/client/src/client_sync/v23/blockchain.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `getblockfrompeer`. #[macro_export] diff --git a/client/src/client_sync/v23/mod.rs b/client/src/client_sync/v23/mod.rs index 761fd16c..f6bed4b9 100644 --- a/client/src/client_sync/v23/mod.rs +++ b/client/src/client_sync/v23/mod.rs @@ -26,7 +26,7 @@ pub use crate::client_sync::{ v21::ImportDescriptorsRequest, }; -crate::define_jsonrpc_minreq_client!("v23"); +crate::define_jsonrpc_bitreq_client!("v23"); crate::impl_client_check_expected_server_version!({ [230200] }); // == Blockchain == diff --git a/client/src/client_sync/v23/wallet.rs b/client/src/client_sync/v23/wallet.rs index f1d0b3de..c615a7d1 100644 --- a/client/src/client_sync/v23/wallet.rs +++ b/client/src/client_sync/v23/wallet.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `createwallet`. #[macro_export] diff --git a/client/src/client_sync/v24/blockchain.rs b/client/src/client_sync/v24/blockchain.rs index d3db015a..df7bb4c6 100644 --- a/client/src/client_sync/v24/blockchain.rs +++ b/client/src/client_sync/v24/blockchain.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `gettxspendingprevout` #[macro_export] diff --git a/client/src/client_sync/v24/mod.rs b/client/src/client_sync/v24/mod.rs index 41ed19fd..427250df 100644 --- a/client/src/client_sync/v24/mod.rs +++ b/client/src/client_sync/v24/mod.rs @@ -26,7 +26,7 @@ pub use crate::client_sync::{ v23::AddressType, }; -crate::define_jsonrpc_minreq_client!("v24"); +crate::define_jsonrpc_bitreq_client!("v24"); crate::impl_client_check_expected_server_version!({ [240200] }); // == Blockchain == diff --git a/client/src/client_sync/v24/wallet.rs b/client/src/client_sync/v24/wallet.rs index 8e030aa4..d259f99f 100644 --- a/client/src/client_sync/v24/wallet.rs +++ b/client/src/client_sync/v24/wallet.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `migratewallet`. #[macro_export] diff --git a/client/src/client_sync/v25/blockchain.rs b/client/src/client_sync/v25/blockchain.rs index 8592352c..9b998eef 100644 --- a/client/src/client_sync/v25/blockchain.rs +++ b/client/src/client_sync/v25/blockchain.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `scanblocks` #[macro_export] diff --git a/client/src/client_sync/v25/generating.rs b/client/src/client_sync/v25/generating.rs index 3aad1314..3b19a19b 100644 --- a/client/src/client_sync/v25/generating.rs +++ b/client/src/client_sync/v25/generating.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `generateblock`. #[macro_export] diff --git a/client/src/client_sync/v25/mod.rs b/client/src/client_sync/v25/mod.rs index 393f0c55..d4fa9aca 100644 --- a/client/src/client_sync/v25/mod.rs +++ b/client/src/client_sync/v25/mod.rs @@ -26,7 +26,7 @@ pub use crate::client_sync::{ v23::AddressType, }; -crate::define_jsonrpc_minreq_client!("v25"); +crate::define_jsonrpc_bitreq_client!("v25"); crate::impl_client_check_expected_server_version!({ [250200] }); // == Blockchain == diff --git a/client/src/client_sync/v26/blockchain.rs b/client/src/client_sync/v26/blockchain.rs index e44ce04b..d9f30f0b 100644 --- a/client/src/client_sync/v26/blockchain.rs +++ b/client/src/client_sync/v26/blockchain.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `dumptxoutset`. #[macro_export] diff --git a/client/src/client_sync/v26/mining.rs b/client/src/client_sync/v26/mining.rs index 2e58a9ef..4a92b5f8 100644 --- a/client/src/client_sync/v26/mining.rs +++ b/client/src/client_sync/v26/mining.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `getprioritisedtransactions`. #[macro_export] diff --git a/client/src/client_sync/v26/mod.rs b/client/src/client_sync/v26/mod.rs index 888ac4fd..d06fefc7 100644 --- a/client/src/client_sync/v26/mod.rs +++ b/client/src/client_sync/v26/mod.rs @@ -28,7 +28,7 @@ pub use crate::client_sync::{ v23::AddressType, }; -crate::define_jsonrpc_minreq_client!("v26"); +crate::define_jsonrpc_bitreq_client!("v26"); crate::impl_client_check_expected_server_version!({ [260000, 260100, 260200] }); // == Blockchain == diff --git a/client/src/client_sync/v26/network.rs b/client/src/client_sync/v26/network.rs index af5cf918..39acb5c5 100644 --- a/client/src/client_sync/v26/network.rs +++ b/client/src/client_sync/v26/network.rs @@ -7,7 +7,7 @@ //! Specifically this is methods found under the `== Network ==` section of the //! API docs of Bitcoin Core `v26`. //! -//! See, or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See, or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `getaddrmaninfo`. #[macro_export] diff --git a/client/src/client_sync/v26/raw_transactions.rs b/client/src/client_sync/v26/raw_transactions.rs index e173b10c..19cf74bb 100644 --- a/client/src/client_sync/v26/raw_transactions.rs +++ b/client/src/client_sync/v26/raw_transactions.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `submitpackage`. #[macro_export] diff --git a/client/src/client_sync/v27/mod.rs b/client/src/client_sync/v27/mod.rs index 56ff9d68..c924ab49 100644 --- a/client/src/client_sync/v27/mod.rs +++ b/client/src/client_sync/v27/mod.rs @@ -23,7 +23,7 @@ pub use crate::client_sync::{ v23::AddressType, }; -crate::define_jsonrpc_minreq_client!("v27"); +crate::define_jsonrpc_bitreq_client!("v27"); crate::impl_client_check_expected_server_version!({ [270000, 270100, 270200] }); // == Blockchain == diff --git a/client/src/client_sync/v28/mod.rs b/client/src/client_sync/v28/mod.rs index e7bac8ea..881758d9 100644 --- a/client/src/client_sync/v28/mod.rs +++ b/client/src/client_sync/v28/mod.rs @@ -26,7 +26,7 @@ pub use crate::client_sync::{ v23::AddressType, }; -crate::define_jsonrpc_minreq_client!("v28"); +crate::define_jsonrpc_bitreq_client!("v28"); crate::impl_client_check_expected_server_version!({ [280000, 280100, 280200] }); // == Blockchain == diff --git a/client/src/client_sync/v28/raw_transactions.rs b/client/src/client_sync/v28/raw_transactions.rs index 14b38696..de8f1db9 100644 --- a/client/src/client_sync/v28/raw_transactions.rs +++ b/client/src/client_sync/v28/raw_transactions.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `submitpackage`. #[macro_export] diff --git a/client/src/client_sync/v28/wallet.rs b/client/src/client_sync/v28/wallet.rs index 1ef32cae..8173f8ea 100644 --- a/client/src/client_sync/v28/wallet.rs +++ b/client/src/client_sync/v28/wallet.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `gethdkeys`. #[macro_export] diff --git a/client/src/client_sync/v29/blockchain.rs b/client/src/client_sync/v29/blockchain.rs index 06aac87a..519a368b 100644 --- a/client/src/client_sync/v29/blockchain.rs +++ b/client/src/client_sync/v29/blockchain.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `dumptxoutset`. #[macro_export] diff --git a/client/src/client_sync/v29/mod.rs b/client/src/client_sync/v29/mod.rs index 7a6a5b81..16160bbb 100644 --- a/client/src/client_sync/v29/mod.rs +++ b/client/src/client_sync/v29/mod.rs @@ -25,7 +25,7 @@ pub use crate::client_sync::{ v23::AddressType, }; -crate::define_jsonrpc_minreq_client!("v29"); +crate::define_jsonrpc_bitreq_client!("v29"); crate::impl_client_check_expected_server_version!({ [290000] }); // == Blockchain == diff --git a/client/src/client_sync/v29/util.rs b/client/src/client_sync/v29/util.rs index 87ed5f25..968799ee 100644 --- a/client/src/client_sync/v29/util.rs +++ b/client/src/client_sync/v29/util.rs @@ -7,7 +7,7 @@ //! //! All macros require `Client` to be in scope. //! -//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`. +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. /// Implements Bitcoin Core JSON-RPC API method `deriveaddresses`. #[macro_export] diff --git a/client/src/client_sync/v30/mod.rs b/client/src/client_sync/v30/mod.rs index 73a2d9ca..3446ae0e 100644 --- a/client/src/client_sync/v30/mod.rs +++ b/client/src/client_sync/v30/mod.rs @@ -22,7 +22,7 @@ pub use crate::client_sync::{ v29::{TemplateRequest, TemplateRules} }; -crate::define_jsonrpc_minreq_client!("v30"); +crate::define_jsonrpc_bitreq_client!("v30"); crate::impl_client_check_expected_server_version!({ [300000] }); // == Blockchain == diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index c5c4dc77..ac142228 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -11,7 +11,7 @@ cargo-fuzz = true [dependencies] honggfuzz = { version = "0.5.55", default-features = false } -jsonrpc = { path = "..", features = ["minreq_http"] } +jsonrpc = { path = "..", features = ["bitreq_http"] } serde = { version = "1.0.103", features = [ "derive" ] } serde_json = "1.0" @@ -20,8 +20,8 @@ serde_json = "1.0" unexpected_cfgs = { level = "deny", check-cfg = ['cfg(fuzzing)'] } [[bin]] -name = "minreq_http" -path = "fuzz_targets/minreq_http.rs" +name = "bitreq_http" +path = "fuzz_targets/bitreq_http.rs" [[bin]] name = "simple_http" diff --git a/fuzz/fuzz_targets/minreq_http.rs b/fuzz/fuzz_targets/bitreq_http.rs similarity index 92% rename from fuzz/fuzz_targets/minreq_http.rs rename to fuzz/fuzz_targets/bitreq_http.rs index ea358b30..90416ee0 100644 --- a/fuzz/fuzz_targets/minreq_http.rs +++ b/fuzz/fuzz_targets/bitreq_http.rs @@ -8,12 +8,12 @@ fn do_test(data: &[u8]) { { use std::io; - use jsonrpc::minreq_http::{MinreqHttpTransport, FUZZ_TCP_SOCK}; + use jsonrpc::bitreq_http::{BitreqHttpTransport, FUZZ_TCP_SOCK}; use jsonrpc::Client; *FUZZ_TCP_SOCK.lock().unwrap() = Some(io::Cursor::new(data.to_vec())); - let t = MinreqHttpTransport::builder() + let t = BitreqHttpTransport::builder() .url("localhost:123") .expect("parse url") .basic_auth("".to_string(), None) diff --git a/fuzz/generate-files.sh b/fuzz/generate-files.sh index bcc0eeef..9afe14bd 100755 --- a/fuzz/generate-files.sh +++ b/fuzz/generate-files.sh @@ -23,7 +23,7 @@ cargo-fuzz = true [dependencies] honggfuzz = { version = "0.5.55", default-features = false } -jsonrpc = { path = "..", features = ["minreq_http"] } +jsonrpc = { path = "..", features = ["bitreq_http"] } serde = { version = "1.0.103", features = [ "derive" ] } serde_json = "1.0" diff --git a/jsonrpc/Cargo.toml b/jsonrpc/Cargo.toml index 62f4fda3..4ec08b1b 100644 --- a/jsonrpc/Cargo.toml +++ b/jsonrpc/Cargo.toml @@ -20,8 +20,8 @@ rustdoc-args = ["--cfg", "docsrs"] default = [ "simple_http", "simple_tcp" ] # A bare-minimum HTTP transport. simple_http = [ "base64" ] -# A transport that uses `minreq` as the HTTP client. -minreq_http = [ "base64", "minreq" ] +# A transport that uses `bitreq` as the HTTP client. +bitreq_http = [ "base64", "bitreq" ] # Basic transport over a raw TcpListener simple_tcp = [] # Basic transport over a raw UnixStream @@ -34,7 +34,7 @@ serde = { version = "1", features = ["derive"] } serde_json = { version = "1", features = [ "raw_value" ] } base64 = { version = "0.22.1", optional = true } -minreq = { version = "2.7.0", features = ["json-using-serde"], optional = true } +bitreq = { version = "0.1.0", path = "../bitreq", features = ["json-using-serde"], optional = true } socks = { version = "0.3.4", optional = true} [lints.rust] diff --git a/jsonrpc/contrib/test_vars.sh b/jsonrpc/contrib/test_vars.sh index 72d3c963..56bcb8eb 100644 --- a/jsonrpc/contrib/test_vars.sh +++ b/jsonrpc/contrib/test_vars.sh @@ -4,7 +4,7 @@ FEATURES_WITH_STD="" # So this is the var to use for all tests. -FEATURES_WITHOUT_STD="simple_http minreq_http simple_tcp simple_uds proxy" +FEATURES_WITHOUT_STD="simple_http bitreq_http simple_tcp simple_uds proxy" # Run these examples. EXAMPLES="" diff --git a/jsonrpc/src/http/minreq_http.rs b/jsonrpc/src/http/bitreq_http.rs similarity index 84% rename from jsonrpc/src/http/minreq_http.rs rename to jsonrpc/src/http/bitreq_http.rs index 05afba6d..20903bfc 100644 --- a/jsonrpc/src/http/minreq_http.rs +++ b/jsonrpc/src/http/bitreq_http.rs @@ -1,7 +1,7 @@ -//! This module implements the [`crate::client::Transport`] trait using [`minreq`] +//! This module implements the [`crate::client::Transport`] trait using [`bitreq`] //! as the underlying HTTP transport. //! -//! [minreq]: +//! [bitreq]: #[cfg(jsonrpc_fuzz)] use std::io::{self, Read, Write}; @@ -23,9 +23,9 @@ const DEFAULT_TIMEOUT_SECONDS: u64 = 15; #[cfg(jsonrpc_fuzz)] const DEFAULT_TIMEOUT_SECONDS: u64 = 1; -/// An HTTP transport that uses [`minreq`] and is useful for running a bitcoind RPC client. +/// An HTTP transport that uses [`bitreq`] and is useful for running a bitcoind RPC client. #[derive(Clone, Debug)] -pub struct MinreqHttpTransport { +pub struct BitreqHttpTransport { /// URL of the RPC server. url: String, /// Timeout only supports second granularity. @@ -34,9 +34,9 @@ pub struct MinreqHttpTransport { basic_auth: Option, } -impl Default for MinreqHttpTransport { +impl Default for BitreqHttpTransport { fn default() -> Self { - MinreqHttpTransport { + BitreqHttpTransport { url: format!("{}:{}", DEFAULT_URL, DEFAULT_PORT), timeout: Duration::from_secs(DEFAULT_TIMEOUT_SECONDS), basic_auth: None, @@ -44,11 +44,11 @@ impl Default for MinreqHttpTransport { } } -impl MinreqHttpTransport { - /// Constructs a new [`MinreqHttpTransport`] with default parameters. - pub fn new() -> Self { MinreqHttpTransport::default() } +impl BitreqHttpTransport { + /// Constructs a new [`BitreqHttpTransport`] with default parameters. + pub fn new() -> Self { BitreqHttpTransport::default() } - /// Returns a builder for [`MinreqHttpTransport`]. + /// Returns a builder for [`BitreqHttpTransport`]. pub fn builder() -> Builder { Builder::new() } fn request(&self, req: impl serde::Serialize) -> Result @@ -56,11 +56,11 @@ impl MinreqHttpTransport { R: for<'a> serde::de::Deserialize<'a>, { let req = match &self.basic_auth { - Some(auth) => minreq::Request::new(minreq::Method::Post, &self.url) + Some(auth) => bitreq::Request::new(bitreq::Method::Post, &self.url) .with_timeout(self.timeout.as_secs()) .with_header("Authorization", auth) .with_json(&req)?, - None => minreq::Request::new(minreq::Method::Post, &self.url) + None => bitreq::Request::new(bitreq::Method::Post, &self.url) .with_timeout(self.timeout.as_secs()) .with_json(&req)?, }; @@ -71,20 +71,20 @@ impl MinreqHttpTransport { let resp = req.send()?; match resp.json() { Ok(json) => Ok(json), - Err(minreq_err) => + Err(bitreq_err) => if resp.status_code != 200 { Err(Error::Http(HttpError { status_code: resp.status_code, body: resp.as_str().unwrap_or("").to_string(), })) } else { - Err(Error::Minreq(minreq_err)) + Err(Error::Bitreq(bitreq_err)) }, } } } -impl Transport for MinreqHttpTransport { +impl Transport for BitreqHttpTransport { fn send_request(&self, req: Request) -> Result { Ok(self.request(req)?) } @@ -96,15 +96,15 @@ impl Transport for MinreqHttpTransport { fn fmt_target(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.url) } } -/// Builder for simple bitcoind [`MinreqHttpTransport`]. +/// Builder for simple bitcoind [`BitreqHttpTransport`]. #[derive(Clone, Debug)] pub struct Builder { - tp: MinreqHttpTransport, + tp: BitreqHttpTransport, } impl Builder { /// Constructs a new [`Builder`] with default configuration and the URL to use. - pub fn new() -> Builder { Builder { tp: MinreqHttpTransport::new() } } + pub fn new() -> Builder { Builder { tp: BitreqHttpTransport::new() } } /// Sets the timeout after which requests will abort if they aren't finished. pub fn timeout(mut self, timeout: Duration) -> Self { @@ -137,22 +137,22 @@ impl Builder { /// # Examples /// /// ```no_run - /// # use jsonrpc::minreq_http::MinreqHttpTransport; + /// # use jsonrpc::bitreq_http::BitreqHttpTransport; /// # use std::fs::{self, File}; /// # use std::path::Path; /// # let cookie_file = Path::new("~/.bitcoind/.cookie"); /// let mut file = File::open(cookie_file).expect("couldn't open cookie file"); /// let mut cookie = String::new(); /// fs::read_to_string(&mut cookie).expect("couldn't read cookie file"); - /// let client = MinreqHttpTransport::builder().cookie_auth(cookie); + /// let client = BitreqHttpTransport::builder().cookie_auth(cookie); /// ``` pub fn cookie_auth>(mut self, cookie: S) -> Self { self.tp.basic_auth = Some(format!("Basic {}", &BASE64.encode(cookie.as_ref().as_bytes()))); self } - /// Builds the final [`MinreqHttpTransport`]. - pub fn build(self) -> MinreqHttpTransport { self.tp } + /// Builds the final [`BitreqHttpTransport`]. + pub fn build(self) -> BitreqHttpTransport { self.tp } } impl Default for Builder { @@ -185,8 +185,8 @@ impl error::Error for HttpError {} pub enum Error { /// JSON parsing error. Json(serde_json::Error), - /// Minreq error. - Minreq(minreq::Error), + /// Bitreq error. + Bitreq(bitreq::Error), /// HTTP error that does not contain valid JSON as body. Http(HttpError), } @@ -195,7 +195,7 @@ impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { Error::Json(ref e) => write!(f, "parsing JSON failed: {}", e), - Error::Minreq(ref e) => write!(f, "minreq: {}", e), + Error::Bitreq(ref e) => write!(f, "bitreq: {}", e), Error::Http(ref e) => write!(f, "http ({})", e), } } @@ -207,7 +207,7 @@ impl error::Error for Error { match *self { Json(ref e) => Some(e), - Minreq(ref e) => Some(e), + Bitreq(ref e) => Some(e), Http(ref e) => Some(e), } } @@ -217,8 +217,8 @@ impl From for Error { fn from(e: serde_json::Error) -> Self { Error::Json(e) } } -impl From for Error { - fn from(e: minreq::Error) -> Self { Error::Minreq(e) } +impl From for Error { + fn from(e: bitreq::Error) -> Self { Error::Bitreq(e) } } impl From for crate::Error { diff --git a/jsonrpc/src/http/mod.rs b/jsonrpc/src/http/mod.rs index 318d8c29..f6221f38 100644 --- a/jsonrpc/src/http/mod.rs +++ b/jsonrpc/src/http/mod.rs @@ -3,8 +3,8 @@ #[cfg(feature = "simple_http")] pub mod simple_http; -#[cfg(feature = "minreq_http")] -pub mod minreq_http; +#[cfg(feature = "bitreq_http")] +pub mod bitreq_http; /// The default TCP port to use for connections. /// Set to 8332, the default RPC port for bitcoind. diff --git a/jsonrpc/src/lib.rs b/jsonrpc/src/lib.rs index f6a3c690..473eba27 100644 --- a/jsonrpc/src/lib.rs +++ b/jsonrpc/src/lib.rs @@ -17,16 +17,16 @@ pub extern crate serde_json; #[cfg(feature = "base64")] pub extern crate base64; -/// Re-export `minreq` crate if the feature is set. -#[cfg(feature = "minreq")] -pub extern crate minreq; +/// Re-export `bitreq` crate if the feature is set. +#[cfg(feature = "bitreq")] +pub extern crate bitreq; pub mod client; pub mod error; pub mod http; -#[cfg(feature = "minreq_http")] -pub use http::minreq_http; +#[cfg(feature = "bitreq_http")] +pub use http::bitreq_http; #[cfg(feature = "simple_http")] pub use http::simple_http; diff --git a/node/Cargo.toml b/node/Cargo.toml index 9c9b2b4e..6aa9fa15 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -27,7 +27,7 @@ env_logger = { version = "0.9.3", default-features = false } anyhow = { version = "1.0.66", optional = true } bitcoin_hashes = { version = ">= 0.13, <= 0.14", optional = true } flate2 = { version = "1.0", optional = true } -minreq = { version = "2.9.1", default-features = false, features = ["https"], optional = true } +bitreq = { version = "0.1.0", path = "../bitreq", features = ["https"], optional = true } tar = { version = "0.4", optional = true } zip = { version = "0.6.6", default-features = false, features = ["bzip2", "deflate"], optional = true } @@ -42,7 +42,7 @@ zip = { version = "0.6.6", default-features = false, features = ["bzip2", "defla [features] default = ["0_17_2"] -download = ["anyhow", "bitcoin_hashes", "flate2", "tar", "minreq", "zip"] +download = ["anyhow", "bitcoin_hashes", "flate2", "tar", "bitreq", "zip"] # We support all minor releases of the latest four versions. 30_0 = ["29_0"] diff --git a/node/build.rs b/node/build.rs index dfec7348..0bdd55d8 100644 --- a/node/build.rs +++ b/node/build.rs @@ -90,7 +90,7 @@ mod download { "{}/bitcoin-core-{}/{}", download_endpoint, VERSION, download_filename ); - let resp = minreq::get(&url) + let resp = bitreq::get(&url) .send() .with_context(|| format!("cannot reach url {}", url))?; assert_eq!(resp.status_code, 200, "url {} didn't return 200", url);