Skip to content

Commit c29fd55

Browse files
committed
Merge #388: Add waitforblock, waitforblockheight and waitfornewblock
8b0a914 Add new waitforX RPCs (Jamil Lambert, PhD) b158065 Move test code into test function (Jamil Lambert, PhD) 7230e61 Remove redundant test (Jamil Lambert, PhD) 340a3e8 Update rustdocs for the Hidden RPC client (Jamil Lambert, PhD) Pull request description: `waitforblock`, `waitforblockheight` and `waitfornewblock` were added to the Core API docs in v30 under blockchain. The RPCs have been there since before v17. Add the RPCs to v17, and add to the types table in v30. - The hidden module in v21 had a copy-paste error and stated it was for the `generating` section. - Update the documentation to state that the methods are `hidden`. - `blockchain__get_tx_out_proof__modelled` is identical to `blockchain__verify_tx_out_proof__modelled`, and the method `gettxoutproof` is tested above in `blockchain__get_tx_out_proof`. - Remove the redundant test. - The model part of the `verify_tx_out_proof` test was in it's own function that the test function called. Other tests all check the model in the same test. - Combine them into one function. - Place it in the correct location. - Remove associated import. - Add `waitforblock`, `waitforblockheight` and `waitfornewblock` methods to v17. They are hidden until v30 with no changes. ACKs for top commit: tcharding: ACK 8b0a914 Tree-SHA512: 7e7c119cb22c3549d9f0e496aabc1727dc4bd51400009fdcc7769d18b6645e52c33aa3549dcad37a099a67cbbd8d9bfef24f3b7912f7d54b44a1c7418caee162
2 parents e022b7c + 8b0a914 commit c29fd55

File tree

36 files changed

+445
-46
lines changed

36 files changed

+445
-46
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// SPDX-License-Identifier: CC0-1.0
2+
3+
//! Macros for implementing JSON-RPC methods on a client.
4+
//!
5+
//! Specifically this is `== Hidden ==` methods that are not listed in the
6+
//! API docs of Bitcoin Core `v0.17`.
7+
//!
8+
//! All macros require `Client` to be in scope.
9+
//!
10+
//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`.
11+
12+
/// Implements Bitcoin Core JSON-RPC API method `waitforblock`.
13+
#[macro_export]
14+
macro_rules! impl_client_v17__wait_for_block {
15+
() => {
16+
impl Client {
17+
pub fn wait_for_block(&self, hash: &bitcoin::BlockHash) -> Result<WaitForBlock> {
18+
self.call("waitforblock", &[into_json(hash)?])
19+
}
20+
}
21+
};
22+
}
23+
24+
/// Implements Bitcoin Core JSON-RPC API method `waitforblockheight`.
25+
#[macro_export]
26+
macro_rules! impl_client_v17__wait_for_block_height {
27+
() => {
28+
impl Client {
29+
pub fn wait_for_block_height(&self, height: u64) -> Result<WaitForBlockHeight> {
30+
self.call("waitforblockheight", &[into_json(height)?])
31+
}
32+
}
33+
};
34+
}
35+
36+
/// Implements Bitcoin Core JSON-RPC API method `waitfornewblock`.
37+
#[macro_export]
38+
macro_rules! impl_client_v17__wait_for_new_block {
39+
() => {
40+
impl Client {
41+
pub fn wait_for_new_block(&self) -> Result<WaitForNewBlock> {
42+
self.call("waitfornewblock", &[])
43+
}
44+
}
45+
};
46+
}

client/src/client_sync/v17/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
pub mod blockchain;
88
pub mod control;
99
pub mod generating;
10+
pub mod hidden;
1011
pub mod mining;
1112
pub mod network;
1213
pub mod raw_transactions;
@@ -64,6 +65,11 @@ crate::impl_client_v17__generate_to_address!();
6465
crate::impl_client_v17__generate!();
6566
crate::impl_client_v17__invalidate_block!();
6667

68+
// == Hidden ==
69+
crate::impl_client_v17__wait_for_block!();
70+
crate::impl_client_v17__wait_for_block_height!();
71+
crate::impl_client_v17__wait_for_new_block!();
72+
6773
// == Mining ==
6874
crate::impl_client_v17__get_block_template!();
6975
crate::impl_client_v17__get_mining_info!();

client/src/client_sync/v18/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ crate::impl_client_v17__generate_to_address!();
7070
crate::impl_client_v17__generate!();
7171
crate::impl_client_v17__invalidate_block!();
7272

73+
// == Hidden ==
74+
crate::impl_client_v17__wait_for_block!();
75+
crate::impl_client_v17__wait_for_block_height!();
76+
crate::impl_client_v17__wait_for_new_block!();
77+
7378
// == Mining ==
7479
crate::impl_client_v17__get_block_template!();
7580
crate::impl_client_v17__get_mining_info!();

client/src/client_sync/v19/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ crate::impl_client_v17__uptime!();
6565
crate::impl_client_v17__generate_to_address!();
6666
crate::impl_client_v17__invalidate_block!();
6767

68+
// == Hidden ==
69+
crate::impl_client_v17__wait_for_block!();
70+
crate::impl_client_v17__wait_for_block_height!();
71+
crate::impl_client_v17__wait_for_new_block!();
72+
6873
// == Mining ==
6974
crate::impl_client_v17__get_block_template!();
7075
crate::impl_client_v17__get_mining_info!();

client/src/client_sync/v20/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ crate::impl_client_v17__generate_to_address!();
6565
crate::impl_client_v20__generate_to_descriptor!();
6666
crate::impl_client_v17__invalidate_block!();
6767

68+
// == Hidden ==
69+
crate::impl_client_v17__wait_for_block!();
70+
crate::impl_client_v17__wait_for_block_height!();
71+
crate::impl_client_v17__wait_for_new_block!();
72+
6873
// == Mining ==
6974
crate::impl_client_v17__get_block_template!();
7075
crate::impl_client_v17__get_mining_info!();

client/src/client_sync/v21/hidden.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
//! Macros for implementing JSON-RPC methods on a client.
44
//!
5-
//! Specifically this is methods found under the `== Generating ==` section of the
5+
//! Specifically this is `== Hidden ==` methods that are not listed in the
66
//! API docs of Bitcoin Core `v0.21`.
77
//!
88
//! All macros require `Client` to be in scope.

client/src/client_sync/v21/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ crate::impl_client_v17__invalidate_block!();
7272

7373
// == Hidden ==
7474
crate::impl_client_v21__add_peer_address!();
75+
crate::impl_client_v17__wait_for_block!();
76+
crate::impl_client_v17__wait_for_block_height!();
77+
crate::impl_client_v17__wait_for_new_block!();
7578

7679
// == Mining ==
7780
crate::impl_client_v17__get_block_template!();

client/src/client_sync/v22/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ crate::impl_client_v17__invalidate_block!();
7070

7171
// == Hidden ==
7272
crate::impl_client_v21__add_peer_address!();
73+
crate::impl_client_v17__wait_for_block!();
74+
crate::impl_client_v17__wait_for_block_height!();
75+
crate::impl_client_v17__wait_for_new_block!();
7376

7477
// == Mining ==
7578
crate::impl_client_v17__get_block_template!();

client/src/client_sync/v23/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ crate::impl_client_v17__invalidate_block!();
7373

7474
// == Hidden ==
7575
crate::impl_client_v21__add_peer_address!();
76+
crate::impl_client_v17__wait_for_block!();
77+
crate::impl_client_v17__wait_for_block_height!();
78+
crate::impl_client_v17__wait_for_new_block!();
7679

7780
// == Mining ==
7881
crate::impl_client_v17__get_block_template!();

client/src/client_sync/v24/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ crate::impl_client_v17__invalidate_block!();
7474

7575
// == Hidden ==
7676
crate::impl_client_v21__add_peer_address!();
77+
crate::impl_client_v17__wait_for_block!();
78+
crate::impl_client_v17__wait_for_block_height!();
79+
crate::impl_client_v17__wait_for_new_block!();
7780

7881
// == Mining ==
7982
crate::impl_client_v17__get_block_template!();

0 commit comments

Comments
 (0)