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: diff --git a/.github/workflows/rust.yaml b/.github/workflows/rust.yaml index dfb7868d..72728a8b 100644 --- a/.github/workflows/rust.yaml +++ b/.github/workflows/rust.yaml @@ -70,7 +70,7 @@ jobs: run: ./maintainer-tools/ci/run_task.sh nightly MSRV: # 2 jobs, one per lock file. - name: Test - 1.63.0 toolchain + name: Test - 1.75.0 toolchain runs-on: ubuntu-latest strategy: fail-fast: false @@ -87,7 +87,7 @@ jobs: - name: "Select toolchain" uses: dtolnay/rust-toolchain@stable with: - toolchain: "1.63.0" + toolchain: "1.75.0" - name: "Set dependencies" run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock - name: "Run test script" 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/README.md b/README.md index ffce101c..88fa0e13 100644 --- a/README.md +++ b/README.md @@ -56,6 +56,6 @@ Some code shamelessly stolen from `rust-bitcoincore-rpc` (credit to Steven). ## Minimum Supported Rust Version (MSRV) -This library should always compile with any combination of features on **Rust 1.63.0**. +This library should always compile with any combination of features on **Rust 1.75.0**. Use `Cargo-minimal.lock` to build the MSRV by copying to `Cargo.lock` and building. diff --git a/bitreq/.github/workflows/msrv.yml b/bitreq/.github/workflows/msrv.yml index c85713e8..aede3509 100644 --- a/bitreq/.github/workflows/msrv.yml +++ b/bitreq/.github/workflows/msrv.yml @@ -18,7 +18,7 @@ jobs: - name: Checkout Crate uses: actions/checkout@v3 - name: Checkout Toolchain - uses: dtolnay/rust-toolchain@1.63 + uses: dtolnay/rust-toolchain@1.75 - name: Running test script run: | cargo test diff --git a/bitreq/Cargo.toml b/bitreq/Cargo.toml index bce0dfe6..680d00e4 100644 --- a/bitreq/Cargo.toml +++ b/bitreq/Cargo.toml @@ -10,7 +10,7 @@ keywords = ["http", "https", "client", "request", "json"] categories = ["web-programming::http-client"] license = "ISC" edition = "2021" -rust-version = "1.74.0" +rust-version = "1.75.0" [badges] maintenance = { status = "experimental" } diff --git a/bitreq/README.md b/bitreq/README.md index 1815cd7d..90e940b3 100644 --- a/bitreq/README.md +++ b/bitreq/README.md @@ -40,7 +40,7 @@ We use an MSRV per major release, i.e., with a new major release we reserve the right to change the MSRV. The current major version of this library should always compile with -default features (i.e., `std`) on **Rust 1.63**. Other features may +default features (i.e., `std`) on **Rust 1.75**. Other features may require a higher MSRV. ## License 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..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 @@ -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. diff --git a/client/Cargo.toml b/client/Cargo.toml index 225a281f..08f9ec4a 100644 --- a/client/Cargo.toml +++ b/client/Cargo.toml @@ -9,7 +9,7 @@ categories = ["cryptography::cryptocurrencies"] keywords = ["bitcoin", "bitcoind", "json-rpc"] readme = "README.md" edition = "2021" -rust-version = "1.63.0" +rust-version = "1.75.0" exclude = ["tests", "contrib"] [package.metadata.docs.rs] @@ -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/README.md b/client/README.md index 0579950e..0c09dedd 100644 --- a/client/README.md +++ b/client/README.md @@ -5,7 +5,7 @@ is only a blocking client and is intended to be used in integration testing. ## Minimum Supported Rust Version (MSRV) -This library should always compile with any combination of features on **Rust 1.63.0**. +This library should always compile with any combination of features on **Rust 1.75.0**. ## Licensing 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/hidden.rs b/client/src/client_sync/v17/hidden.rs new file mode 100644 index 00000000..05e305da --- /dev/null +++ b/client/src/client_sync/v17/hidden.rs @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! Macros for implementing JSON-RPC methods on a client. +//! +//! Specifically this is `== Hidden ==` methods that are not listed in the +//! API docs of Bitcoin Core `v0.17`. +//! +//! All macros require `Client` to be in scope. +//! +//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`. + +/// Implements Bitcoin Core JSON-RPC API method `waitforblock`. +#[macro_export] +macro_rules! impl_client_v17__wait_for_block { + () => { + impl Client { + pub fn wait_for_block(&self, hash: &bitcoin::BlockHash) -> Result { + self.call("waitforblock", &[into_json(hash)?]) + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `waitforblockheight`. +#[macro_export] +macro_rules! impl_client_v17__wait_for_block_height { + () => { + impl Client { + pub fn wait_for_block_height(&self, height: u64) -> Result { + self.call("waitforblockheight", &[into_json(height)?]) + } + } + }; +} + +/// Implements Bitcoin Core JSON-RPC API method `waitfornewblock`. +#[macro_export] +macro_rules! impl_client_v17__wait_for_new_block { + () => { + impl Client { + pub fn wait_for_new_block(&self) -> Result { + self.call("waitfornewblock", &[]) + } + } + }; +} 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 58215d5c..7921840d 100644 --- a/client/src/client_sync/v17/mod.rs +++ b/client/src/client_sync/v17/mod.rs @@ -7,6 +7,7 @@ pub mod blockchain; pub mod control; pub mod generating; +pub mod hidden; pub mod mining; pub mod network; pub mod raw_transactions; @@ -24,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 == @@ -64,6 +65,11 @@ crate::impl_client_v17__generate_to_address!(); crate::impl_client_v17__generate!(); crate::impl_client_v17__invalidate_block!(); +// == Hidden == +crate::impl_client_v17__wait_for_block!(); +crate::impl_client_v17__wait_for_block_height!(); +crate::impl_client_v17__wait_for_new_block!(); + // == Mining == crate::impl_client_v17__get_block_template!(); crate::impl_client_v17__get_mining_info!(); 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 7a806ccd..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 == @@ -70,6 +70,11 @@ crate::impl_client_v17__generate_to_address!(); crate::impl_client_v17__generate!(); crate::impl_client_v17__invalidate_block!(); +// == Hidden == +crate::impl_client_v17__wait_for_block!(); +crate::impl_client_v17__wait_for_block_height!(); +crate::impl_client_v17__wait_for_new_block!(); + // == Mining == crate::impl_client_v17__get_block_template!(); crate::impl_client_v17__get_mining_info!(); 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 7cf1d16e..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 == @@ -65,6 +65,11 @@ crate::impl_client_v17__uptime!(); crate::impl_client_v17__generate_to_address!(); crate::impl_client_v17__invalidate_block!(); +// == Hidden == +crate::impl_client_v17__wait_for_block!(); +crate::impl_client_v17__wait_for_block_height!(); +crate::impl_client_v17__wait_for_new_block!(); + // == Mining == crate::impl_client_v17__get_block_template!(); crate::impl_client_v17__get_mining_info!(); 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 21424320..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 == @@ -65,6 +65,11 @@ crate::impl_client_v17__generate_to_address!(); crate::impl_client_v20__generate_to_descriptor!(); crate::impl_client_v17__invalidate_block!(); +// == Hidden == +crate::impl_client_v17__wait_for_block!(); +crate::impl_client_v17__wait_for_block_height!(); +crate::impl_client_v17__wait_for_new_block!(); + // == Mining == crate::impl_client_v17__get_block_template!(); crate::impl_client_v17__get_mining_info!(); 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 fc867510..8e6c9751 100644 --- a/client/src/client_sync/v21/hidden.rs +++ b/client/src/client_sync/v21/hidden.rs @@ -2,12 +2,12 @@ //! Macros for implementing JSON-RPC methods on a client. //! -//! Specifically this is methods found under the `== Generating ==` section of the +//! Specifically this is `== Hidden ==` methods that are not listed in the //! API docs of Bitcoin Core `v0.21`. //! //! 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 58b9d0a8..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 == @@ -72,6 +72,9 @@ crate::impl_client_v17__invalidate_block!(); // == Hidden == crate::impl_client_v21__add_peer_address!(); +crate::impl_client_v17__wait_for_block!(); +crate::impl_client_v17__wait_for_block_height!(); +crate::impl_client_v17__wait_for_new_block!(); // == Mining == crate::impl_client_v17__get_block_template!(); 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 6d32b66f..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 == @@ -70,6 +70,9 @@ crate::impl_client_v17__invalidate_block!(); // == Hidden == crate::impl_client_v21__add_peer_address!(); +crate::impl_client_v17__wait_for_block!(); +crate::impl_client_v17__wait_for_block_height!(); +crate::impl_client_v17__wait_for_new_block!(); // == Mining == crate::impl_client_v17__get_block_template!(); 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 8cc0102e..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 == @@ -73,6 +73,9 @@ crate::impl_client_v17__invalidate_block!(); // == Hidden == crate::impl_client_v21__add_peer_address!(); +crate::impl_client_v17__wait_for_block!(); +crate::impl_client_v17__wait_for_block_height!(); +crate::impl_client_v17__wait_for_new_block!(); // == Mining == crate::impl_client_v17__get_block_template!(); 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 49f4a804..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 == @@ -74,6 +74,9 @@ crate::impl_client_v17__invalidate_block!(); // == Hidden == crate::impl_client_v21__add_peer_address!(); +crate::impl_client_v17__wait_for_block!(); +crate::impl_client_v17__wait_for_block_height!(); +crate::impl_client_v17__wait_for_new_block!(); // == Mining == crate::impl_client_v17__get_block_template!(); 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 36ecc2cc..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 == @@ -75,6 +75,9 @@ crate::impl_client_v17__invalidate_block!(); // == Hidden == crate::impl_client_v21__add_peer_address!(); +crate::impl_client_v17__wait_for_block!(); +crate::impl_client_v17__wait_for_block_height!(); +crate::impl_client_v17__wait_for_new_block!(); // == Mining == crate::impl_client_v17__get_block_template!(); 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 f7fd02f2..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 == @@ -81,6 +81,9 @@ crate::impl_client_v17__invalidate_block!(); // == Hidden == crate::impl_client_v21__add_peer_address!(); +crate::impl_client_v17__wait_for_block!(); +crate::impl_client_v17__wait_for_block_height!(); +crate::impl_client_v17__wait_for_new_block!(); // == Mining == crate::impl_client_v17__get_block_template!(); 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 a4c9f449..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 == @@ -75,6 +75,9 @@ crate::impl_client_v17__invalidate_block!(); // == Hidden == crate::impl_client_v21__add_peer_address!(); +crate::impl_client_v17__wait_for_block!(); +crate::impl_client_v17__wait_for_block_height!(); +crate::impl_client_v17__wait_for_new_block!(); // == Mining == crate::impl_client_v17__get_block_template!(); diff --git a/client/src/client_sync/v28/mod.rs b/client/src/client_sync/v28/mod.rs index 5c2c24bf..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 == @@ -78,6 +78,9 @@ crate::impl_client_v17__invalidate_block!(); // == Hidden == crate::impl_client_v21__add_peer_address!(); +crate::impl_client_v17__wait_for_block!(); +crate::impl_client_v17__wait_for_block_height!(); +crate::impl_client_v17__wait_for_new_block!(); // == Mining == crate::impl_client_v17__get_block_template!(); 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 d8754589..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 == @@ -78,6 +78,9 @@ crate::impl_client_v17__invalidate_block!(); // == Hidden == crate::impl_client_v21__add_peer_address!(); +crate::impl_client_v17__wait_for_block!(); +crate::impl_client_v17__wait_for_block_height!(); +crate::impl_client_v17__wait_for_new_block!(); // == Mining == crate::impl_client_v17__get_block_template!(); 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 e62fa86c..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 == @@ -58,6 +58,9 @@ crate::impl_client_v23__save_mempool!(); crate::impl_client_v25__scan_blocks!(); crate::impl_client_v17__verify_chain!(); crate::impl_client_v17__verify_tx_out_proof!(); +crate::impl_client_v17__wait_for_block!(); +crate::impl_client_v17__wait_for_block_height!(); +crate::impl_client_v17__wait_for_new_block!(); // == Control == crate::impl_client_v17__get_memory_info!(); diff --git a/clippy.toml b/clippy.toml index ddca6b4c..4dc6505e 100644 --- a/clippy.toml +++ b/clippy.toml @@ -1,2 +1,2 @@ -msrv = "1.63.0" +msrv = "1.75.0" too-many-arguments-threshold = 13 diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 741bda61..ac142228 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "jsonrpc-fuzz" edition = "2021" -rust-version = "1.63.0" +rust-version = "1.75.0" version = "0.0.1" authors = ["Generated by fuzz/generate-files.sh"] publish = false @@ -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 dfca1678..9afe14bd 100755 --- a/fuzz/generate-files.sh +++ b/fuzz/generate-files.sh @@ -13,7 +13,7 @@ cat > "$REPO_DIR/fuzz/Cargo.toml" < = node.client.verify_chain(); +} + #[test] fn blockchain__verify_tx_out_proof__modelled() { let node = Node::with_wallet(Wallet::Default, &[]); node.fund_wallet(); - verify_tx_out_proof(&node).unwrap(); + + let (_address, tx) = node.create_mined_transaction(); + let txid = tx.compute_txid(); + + let proof = node.client.get_tx_out_proof(&[txid]).expect("gettxoutproof"); + + let json: VerifyTxOutProof = node.client.verify_tx_out_proof(&proof).expect("verifytxoutproof"); + let model: Result = json.into_model(); + let txids = model.unwrap(); + + // sanity check + assert_eq!(txids.0.len(), 1); } #[test] -fn blockchain__get_tx_out_proof__modelled() { +fn blockchain__wait_for_block__modelled() { let node = Node::with_wallet(Wallet::Default, &[]); node.fund_wallet(); - verify_tx_out_proof(&node).unwrap(); + let (_address, _tx) = node.create_mined_transaction(); + let block_hash = node.client.best_block_hash().expect("bestblockhash"); + + let json: WaitForBlock = node.client.wait_for_block(&block_hash).expect("waitforblock"); + let model: Result = json.into_model(); + let block = model.unwrap(); + assert_eq!(block.hash, block_hash); } #[test] -fn blockchain__verify_chain() { - let node = Node::with_wallet(Wallet::None, &[]); +fn blockchain__wait_for_block_height__modelled() { + let node = Node::with_wallet(Wallet::Default, &[]); + node.fund_wallet(); + let (_address, _tx) = node.create_mined_transaction(); + let height = node.client.get_block_count().expect("getblockcount").0; + let block_hash = node.client.best_block_hash().expect("bestblockhash"); + let target_height = height; - let _: Result = node.client.verify_chain(); + let json: WaitForBlockHeight = + node.client.wait_for_block_height(target_height).expect("waitforblockheight"); + let model: Result = json.into_model(); + let block = model.unwrap(); + assert_eq!(block.height, target_height as u32); + assert_eq!(block.hash, block_hash); } -fn verify_tx_out_proof(node: &Node) -> Result<(), client_sync::Error> { - let (_address, tx) = node.create_mined_transaction(); - let txid = tx.compute_txid(); +#[test] +fn blockchain__wait_for_new_block__modelled() { + let (node1, node2, _node3) = integration_test::three_node_network(); + node1.fund_wallet(); + node1.mine_a_block(); - let proof = node.client.get_tx_out_proof(&[txid])?; + let prev_hash = node1.client.best_block_hash().expect("bestblockhash"); + let prev_height = node1.client.get_block_count().expect("getblockcount").0; - let json: VerifyTxOutProof = node.client.verify_tx_out_proof(&proof)?; - let model: Result = json.into_model(); - let txids = model.unwrap(); + // Start waiting for a new block on node1 in a separate thread. + let handle = std::thread::spawn(move || { + let json: WaitForNewBlock = node1.client.wait_for_new_block().expect("waitfornewblock"); + let model: Result = json.into_model(); + model.unwrap() + }); + std::thread::sleep(std::time::Duration::from_millis(200)); - // sanity check - assert_eq!(txids.0.len(), 1); + // Trigger a new block on node2. + node2.mine_a_block(); - Ok(()) + let block = handle.join().expect("waitfornewblock thread panicked"); + assert_eq!(block.height, (prev_height + 1) as u32); + assert_ne!(block.hash, prev_hash); } /// Create and broadcast a child transaction spending vout 0 of the given parent mempool txid. diff --git a/jsonrpc/Cargo.toml b/jsonrpc/Cargo.toml index 98fc7055..4ec08b1b 100644 --- a/jsonrpc/Cargo.toml +++ b/jsonrpc/Cargo.toml @@ -9,7 +9,7 @@ description = "Rust support for the JSON-RPC 2.0 protocol" keywords = [ "protocol", "json", "http", "jsonrpc" ] readme = "README.md" edition = "2021" -rust-version = "1.63.0" +rust-version = "1.75.0" exclude = ["tests", "contrib"] [package.metadata.docs.rs] @@ -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/README.md b/jsonrpc/README.md index 40cbd5ba..707025c6 100644 --- a/jsonrpc/README.md +++ b/jsonrpc/README.md @@ -2,7 +2,7 @@ # Rust Version compatibility -This library is compatible with Rust **1.63.0** or higher. +This library is compatible with Rust **1.75.0** or higher. # Rust JSONRPC Client 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 f98149a8..6aa9fa15 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -9,7 +9,7 @@ categories = ["cryptography::cryptocurrencies", "development-tools::testing"] keywords = ["bitcoin", "bitcoind", "json-rpc"] readme = "README.md" edition = "2021" -rust-version = "1.63.0" +rust-version = "1.75.0" exclude = ["tests", "contrib"] [dependencies] @@ -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/README.md b/node/README.md index cebc7a19..975386bb 100644 --- a/node/README.md +++ b/node/README.md @@ -57,7 +57,7 @@ RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --features download,doc --open ## Minimum Supported Rust Version (MSRV) -This library should always compile with any combination of features on **Rust 1.63.0**. +This library should always compile with any combination of features on **Rust 1.75.0**. ## Nix 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); diff --git a/types/Cargo.toml b/types/Cargo.toml index d3d4e28d..11e7dd07 100644 --- a/types/Cargo.toml +++ b/types/Cargo.toml @@ -9,7 +9,7 @@ categories = ["cryptography::cryptocurrencies"] keywords = ["bitcoin", "bitcoind", "json-rpc"] readme = "README.md" edition = "2021" -rust-version = "1.63.0" +rust-version = "1.75.0" exclude = ["tests", "contrib"] [features] diff --git a/types/README.md b/types/README.md index 30c1d8d6..5dc216e5 100644 --- a/types/README.md +++ b/types/README.md @@ -31,7 +31,7 @@ testing in the wild. ## Minimum Supported Rust Version (MSRV) -This library should always compile with any combination of features on **Rust 1.63.0**. +This library should always compile with any combination of features on **Rust 1.75.0**. ## Licensing diff --git a/types/src/model/blockchain.rs b/types/src/model/blockchain.rs index 1c43b219..87e18e59 100644 --- a/types/src/model/blockchain.rs +++ b/types/src/model/blockchain.rs @@ -739,3 +739,30 @@ pub struct ScanBlocksStart { /// Models the result of JSON-RPC method `verifytxoutproof`. #[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] pub struct VerifyTxOutProof(pub Vec); + +/// Models the result of JSON-RPC method `waitforblock`. +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct WaitForBlock { + /// The blockhash. + pub hash: BlockHash, + /// Block height. + pub height: u32, +} + +/// Models the result of JSON-RPC method `waitforblockheight`. +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct WaitForBlockHeight { + /// The blockhash. + pub hash: BlockHash, + /// Block height. + pub height: u32, +} + +/// Models the result of JSON-RPC method `waitfornewblock`. +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +pub struct WaitForNewBlock { + /// The blockhash. + pub hash: BlockHash, + /// Block height. + pub height: u32, +} diff --git a/types/src/model/mod.rs b/types/src/model/mod.rs index c414822b..189b4ca2 100644 --- a/types/src/model/mod.rs +++ b/types/src/model/mod.rs @@ -34,7 +34,8 @@ pub use self::{ GetMempoolDescendants, GetMempoolDescendantsVerbose, GetMempoolEntry, GetMempoolInfo, GetRawMempool, GetRawMempoolVerbose, GetTxOut, GetTxOutSetInfo, GetTxSpendingPrevout, GetTxSpendingPrevoutItem, LoadTxOutSet, MempoolEntry, MempoolEntryFees, ReceiveActivity, - ScanBlocksStart, Softfork, SoftforkType, SpendActivity, VerifyTxOutProof, + ScanBlocksStart, Softfork, SoftforkType, SpendActivity, VerifyTxOutProof, WaitForBlock, + WaitForBlockHeight, WaitForNewBlock, }, generating::{Generate, GenerateBlock, GenerateToAddress, GenerateToDescriptor}, mining::{ diff --git a/types/src/v17/hidden/error.rs b/types/src/v17/hidden/error.rs new file mode 100644 index 00000000..f326b6df --- /dev/null +++ b/types/src/v17/hidden/error.rs @@ -0,0 +1,104 @@ +// SPDX-License-Identifier: CC0-1.0 + +use core::fmt; + +use bitcoin::hex; + +use crate::error::write_err; +use crate::NumericError; + +/// Error when converting a `WaitForBlock` type into the model type. +#[derive(Debug)] +pub enum WaitForBlockError { + /// Conversion of numeric type to expected type failed. + Numeric(NumericError), + /// Conversion of the `hash` field failed. + Hash(hex::HexToArrayError), +} + +impl fmt::Display for WaitForBlockError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for WaitForBlockError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match *self { + Self::Numeric(ref e) => Some(e), + Self::Hash(ref e) => Some(e), + } + } +} + +impl From for WaitForBlockError { + fn from(e: NumericError) -> Self { Self::Numeric(e) } +} + +/// Error when converting a `WaitForBlockHeight` type into the model type. +#[derive(Debug)] +pub enum WaitForBlockHeightError { + /// Conversion of numeric type to expected type failed. + Numeric(NumericError), + /// Conversion of the `hash` field failed. + Hash(hex::HexToArrayError), +} + +impl fmt::Display for WaitForBlockHeightError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for WaitForBlockHeightError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match *self { + Self::Numeric(ref e) => Some(e), + Self::Hash(ref e) => Some(e), + } + } +} + +impl From for WaitForBlockHeightError { + fn from(e: NumericError) -> Self { Self::Numeric(e) } +} + +/// Error when converting a `WaitForNewBlock` type into the model type. +#[derive(Debug)] +pub enum WaitForNewBlockError { + /// Conversion of numeric type to expected type failed. + Numeric(NumericError), + /// Conversion of the `hash` field failed. + Hash(hex::HexToArrayError), +} + +impl fmt::Display for WaitForNewBlockError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match *self { + Self::Numeric(ref e) => write_err!(f, "numeric"; e), + Self::Hash(ref e) => write_err!(f, "conversion of the `hash` field failed"; e), + } + } +} + +#[cfg(feature = "std")] +impl std::error::Error for WaitForNewBlockError { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { + match *self { + Self::Numeric(ref e) => Some(e), + Self::Hash(ref e) => Some(e), + } + } +} + +impl From for WaitForNewBlockError { + fn from(e: NumericError) -> Self { Self::Numeric(e) } +} diff --git a/types/src/v17/hidden/into.rs b/types/src/v17/hidden/into.rs new file mode 100644 index 00000000..9027bf4a --- /dev/null +++ b/types/src/v17/hidden/into.rs @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: CC0-1.0 + +use bitcoin::BlockHash; + +use super::{ + WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, + WaitForNewBlockError, +}; +use crate::model; + +impl WaitForBlock { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use WaitForBlockError as E; + + let hash = self.hash.parse::().map_err(E::Hash)?; + + Ok(model::WaitForBlock { hash, height: crate::to_u32(self.height, "height")? }) + } +} + +impl WaitForBlockHeight { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use WaitForBlockHeightError as E; + + let hash = self.hash.parse::().map_err(E::Hash)?; + + Ok(model::WaitForBlockHeight { hash, height: crate::to_u32(self.height, "height")? }) + } +} + +impl WaitForNewBlock { + /// Converts version specific type to a version nonspecific, more strongly typed type. + pub fn into_model(self) -> Result { + use WaitForNewBlockError as E; + + let hash = self.hash.parse::().map_err(E::Hash)?; + + Ok(model::WaitForNewBlock { hash, height: crate::to_u32(self.height, "height")? }) + } +} diff --git a/types/src/v17/hidden/mod.rs b/types/src/v17/hidden/mod.rs new file mode 100644 index 00000000..2001c0d3 --- /dev/null +++ b/types/src/v17/hidden/mod.rs @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: CC0-1.0 + +//! The JSON-RPC API for Bitcoin Core `v0.17` - hidden. +//! +//! Types for methods that are excluded from the API docs by default. + +mod error; +mod into; + +use serde::{Deserialize, Serialize}; + +pub use self::error::{WaitForBlockError, WaitForBlockHeightError, WaitForNewBlockError}; + +/// Result of JSON-RPC method `waitforblock`. +/// +/// > waitforblock "blockhash" ( timeout ) +/// > +/// > Waits for a specific new block and returns useful info about it. +/// > +/// > Returns the current block on timeout or exit. +/// > +/// > Arguments: +/// > 1. "blockhash" (string, required) Block hash to wait for. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct WaitForBlock { + /// The blockhash. + pub hash: String, + /// Block height. + pub height: i64, +} + +/// Result of JSON-RPC method `waitforblockheight`. +/// +/// > waitforblockheight "height" ( timeout ) +/// > +/// > Waits for (at least) block height and returns the height and hash +/// > of the current tip. +/// > +/// > Arguments: +/// > 1. "blockhash" (string, required) Block hash to wait for +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct WaitForBlockHeight { + /// The blockhash. + pub hash: String, + /// Block height. + pub height: i64, +} + +/// Result of JSON-RPC method `waitfornewblock`. +/// +/// > waitfornewblock ( timeout "current_tip" ) +/// > +/// > Waits for any new block and returns useful info about it. +/// > +/// > Returns the current block on timeout or exit. +#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)] +#[cfg_attr(feature = "serde-deny-unknown-fields", serde(deny_unknown_fields))] +pub struct WaitForNewBlock { + /// The blockhash. + pub hash: String, + /// Block height. + pub height: i64, +} diff --git a/types/src/v17/mod.rs b/types/src/v17/mod.rs index 44125f64..f6bfed6b 100644 --- a/types/src/v17/mod.rs +++ b/types/src/v17/mod.rs @@ -224,6 +224,7 @@ mod blockchain; mod control; mod generating; +mod hidden; mod mining; mod network; pub(crate) mod raw_transactions; @@ -248,6 +249,10 @@ pub use self::{ }, control::{GetMemoryInfoStats, Locked, Logging}, generating::{Generate, GenerateToAddress}, + hidden::{ + WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, + WaitForNewBlock, WaitForNewBlockError, + }, mining::{ BlockTemplateTransaction, BlockTemplateTransactionError, GetBlockTemplate, GetBlockTemplateError, GetMiningInfo, diff --git a/types/src/v18/mod.rs b/types/src/v18/mod.rs index 9f719e05..9177f138 100644 --- a/types/src/v18/mod.rs +++ b/types/src/v18/mod.rs @@ -285,6 +285,7 @@ pub use crate::v17::{ SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, Softfork, SoftforkReject, TestMempoolAccept, TransactionCategory, TransactionItem, TransactionItemError, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, - VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, - WitnessUtxo, + VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, + WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, + WalletProcessPsbt, WitnessUtxo, }; diff --git a/types/src/v19/mod.rs b/types/src/v19/mod.rs index 81f8cd73..26378399 100644 --- a/types/src/v19/mod.rs +++ b/types/src/v19/mod.rs @@ -277,8 +277,10 @@ pub use crate::v17::{ SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TestMempoolAccept, TransactionCategory, TransactionItem, TransactionItemError, UploadTarget, ValidateAddress, - ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, - WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, + ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, WaitForBlock, + WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, WaitForNewBlock, + WaitForNewBlockError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WalletProcessPsbt, + WitnessUtxo, }; #[doc(inline)] pub use crate::v18::{ diff --git a/types/src/v20/mod.rs b/types/src/v20/mod.rs index 0e20fd37..137ce467 100644 --- a/types/src/v20/mod.rs +++ b/types/src/v20/mod.rs @@ -272,8 +272,9 @@ pub use crate::{ SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TestMempoolAccept, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, - VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, - WalletProcessPsbt, WitnessUtxo, + VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, + WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, diff --git a/types/src/v21/mod.rs b/types/src/v21/mod.rs index a42db85c..066ff55c 100644 --- a/types/src/v21/mod.rs +++ b/types/src/v21/mod.rs @@ -288,8 +288,9 @@ pub use crate::{ SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, - VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, - WalletProcessPsbt, WitnessUtxo, + VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, + WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, diff --git a/types/src/v22/mod.rs b/types/src/v22/mod.rs index a1b6193f..91bcaab5 100644 --- a/types/src/v22/mod.rs +++ b/types/src/v22/mod.rs @@ -290,8 +290,9 @@ pub use crate::{ SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, - VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, - WalletProcessPsbt, WitnessUtxo, + VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, + WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, diff --git a/types/src/v23/mod.rs b/types/src/v23/mod.rs index 292c8917..9779728a 100644 --- a/types/src/v23/mod.rs +++ b/types/src/v23/mod.rs @@ -291,8 +291,9 @@ pub use crate::{ SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, - VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, - WalletProcessPsbt, WitnessUtxo, + VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, + WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, diff --git a/types/src/v24/mod.rs b/types/src/v24/mod.rs index 8728519c..50be7bbe 100644 --- a/types/src/v24/mod.rs +++ b/types/src/v24/mod.rs @@ -290,8 +290,9 @@ pub use crate::{ SetTxFee, SignMessage, SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, - VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, - WalletProcessPsbt, WitnessUtxo, + VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, + WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, diff --git a/types/src/v25/mod.rs b/types/src/v25/mod.rs index d186e22d..24132b7d 100644 --- a/types/src/v25/mod.rs +++ b/types/src/v25/mod.rs @@ -285,8 +285,9 @@ pub use crate::{ SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, - VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, - WalletProcessPsbt, WitnessUtxo, + VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, + WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WalletProcessPsbt, WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, diff --git a/types/src/v26/mod.rs b/types/src/v26/mod.rs index f2588ab3..be48a17f 100644 --- a/types/src/v26/mod.rs +++ b/types/src/v26/mod.rs @@ -303,8 +303,9 @@ pub use crate::{ SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, - VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, - WitnessUtxo, + VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, + WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, diff --git a/types/src/v27/mod.rs b/types/src/v27/mod.rs index 45e4b723..7a80045b 100644 --- a/types/src/v27/mod.rs +++ b/types/src/v27/mod.rs @@ -279,8 +279,9 @@ pub use crate::{ SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, - VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, - WitnessUtxo, + VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, + WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, diff --git a/types/src/v28/mod.rs b/types/src/v28/mod.rs index 50b96b80..302784e8 100644 --- a/types/src/v28/mod.rs +++ b/types/src/v28/mod.rs @@ -300,8 +300,9 @@ pub use crate::{ SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, SoftforkReject, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, - VerifyMessage, VerifyTxOutProof, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, - WitnessUtxo, + VerifyMessage, VerifyTxOutProof, WaitForBlock, WaitForBlockError, WaitForBlockHeight, + WaitForBlockHeightError, WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, + WalletCreateFundedPsbtError, WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, diff --git a/types/src/v29/mod.rs b/types/src/v29/mod.rs index b5be8c28..a2e5a6ca 100644 --- a/types/src/v29/mod.rs +++ b/types/src/v29/mod.rs @@ -293,7 +293,9 @@ pub use crate::{ SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, - WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WitnessUtxo, + WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, + WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, + WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing, diff --git a/types/src/v30/mod.rs b/types/src/v30/mod.rs index 1442de44..cd73423e 100644 --- a/types/src/v30/mod.rs +++ b/types/src/v30/mod.rs @@ -60,9 +60,9 @@ //! | scantxoutset | omitted | API marked as experimental | //! | verifychain | version | | //! | verifytxoutproof | version + model | | -//! | waitforblock | version + model | TODO | -//! | waitforblockheight | version + model | TODO | -//! | waitfornewblock | version + model | TODO | +//! | waitforblock | version + model | | +//! | waitforblockheight | version + model | | +//! | waitfornewblock | version + model | | //! //! //! @@ -265,7 +265,9 @@ pub use crate::{ SignMessageWithPrivKey, SignRawTransaction, SignRawTransactionError, SignRawTransactionWithKey, SignRawTransactionWithWallet, TransactionCategory, UploadTarget, ValidateAddress, ValidateAddressError, VerifyChain, VerifyMessage, VerifyTxOutProof, - WalletCreateFundedPsbt, WalletCreateFundedPsbtError, WitnessUtxo, + WaitForBlock, WaitForBlockError, WaitForBlockHeight, WaitForBlockHeightError, + WaitForNewBlock, WaitForNewBlockError, WalletCreateFundedPsbt, WalletCreateFundedPsbtError, + WitnessUtxo, }, v18::{ ActiveCommand, AnalyzePsbt, AnalyzePsbtError, AnalyzePsbtInput, AnalyzePsbtInputMissing,