Skip to content

Commit b453c71

Browse files
committed
Implement addconnection in hidden
Implement the RPC in v22 hidden module, add the client macro, model and test. Redefine the client macro in v27 where there is an added required argument. Add all the reexports up to v30.
1 parent 65e7637 commit b453c71

File tree

25 files changed

+169
-21
lines changed

25 files changed

+169
-21
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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 `v22`.
7+
//!
8+
//! All macros require `Client` to be in scope.
9+
//!
10+
//! See, or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`.
11+
12+
/// Implements Bitcoin Core JSON-RPC API method `addconnection`.
13+
#[macro_export]
14+
macro_rules! impl_client_v22__add_connection {
15+
() => {
16+
impl Client {
17+
pub fn add_connection(
18+
&self,
19+
address: &str,
20+
connection_type: &str,
21+
) -> Result<AddConnection> {
22+
self.call("addconnection", &[into_json(address)?, into_json(connection_type)?])
23+
}
24+
}
25+
};
26+
}

client/src/client_sync/v22/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//!
55
//! We ignore option arguments unless they effect the shape of the returned JSON data.
66
7+
mod hidden;
78
mod signer;
89
mod wallet;
910

@@ -69,6 +70,7 @@ crate::impl_client_v20__generate_to_descriptor!();
6970
crate::impl_client_v17__invalidate_block!();
7071

7172
// == Hidden ==
73+
crate::impl_client_v22__add_connection!();
7274
crate::impl_client_v21__add_peer_address!();
7375
crate::impl_client_v17__estimate_raw_fee!();
7476
crate::impl_client_v17__wait_for_block!();

client/src/client_sync/v23/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ crate::impl_client_v20__generate_to_descriptor!();
7272
crate::impl_client_v17__invalidate_block!();
7373

7474
// == Hidden ==
75+
crate::impl_client_v22__add_connection!();
7576
crate::impl_client_v21__add_peer_address!();
7677
crate::impl_client_v17__estimate_raw_fee!();
7778
crate::impl_client_v17__wait_for_block!();

client/src/client_sync/v24/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ crate::impl_client_v20__generate_to_descriptor!();
7373
crate::impl_client_v17__invalidate_block!();
7474

7575
// == Hidden ==
76+
crate::impl_client_v22__add_connection!();
7677
crate::impl_client_v21__add_peer_address!();
7778
crate::impl_client_v17__estimate_raw_fee!();
7879
crate::impl_client_v17__wait_for_block!();

client/src/client_sync/v25/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ crate::impl_client_v20__generate_to_descriptor!();
7474
crate::impl_client_v17__invalidate_block!();
7575

7676
// == Hidden ==
77+
crate::impl_client_v22__add_connection!();
7778
crate::impl_client_v21__add_peer_address!();
7879
crate::impl_client_v17__estimate_raw_fee!();
7980
crate::impl_client_v17__wait_for_block!();

client/src/client_sync/v26/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ crate::impl_client_v20__generate_to_descriptor!();
8080
crate::impl_client_v17__invalidate_block!();
8181

8282
// == Hidden ==
83+
crate::impl_client_v22__add_connection!();
8384
crate::impl_client_v21__add_peer_address!();
8485
crate::impl_client_v17__estimate_raw_fee!();
8586
crate::impl_client_v17__wait_for_block!();
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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 `v29`.
7+
//!
8+
//! All macros require `Client` to be in scope.
9+
//!
10+
//! See, or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`.
11+
12+
/// Implements Bitcoin Core JSON-RPC API method `addconnection`.
13+
#[macro_export]
14+
macro_rules! impl_client_v27__add_connection {
15+
() => {
16+
impl Client {
17+
pub fn add_connection(
18+
&self,
19+
address: &str,
20+
connection_type: &str,
21+
v2transport: bool,
22+
) -> Result<AddConnection> {
23+
self.call(
24+
"addconnection",
25+
&[into_json(address)?, into_json(connection_type)?, into_json(v2transport)?],
26+
)
27+
}
28+
}
29+
};
30+
}

client/src/client_sync/v27/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
//!
55
//! We ignore option arguments unless they effect the shape of the returned JSON data.
66
7+
pub mod hidden;
8+
79
use std::collections::BTreeMap;
810
use std::path::Path;
911

@@ -74,6 +76,7 @@ crate::impl_client_v20__generate_to_descriptor!();
7476
crate::impl_client_v17__invalidate_block!();
7577

7678
// == Hidden ==
79+
crate::impl_client_v27__add_connection!();
7780
crate::impl_client_v21__add_peer_address!();
7881
crate::impl_client_v17__estimate_raw_fee!();
7982
crate::impl_client_v17__wait_for_block!();

client/src/client_sync/v28/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ crate::impl_client_v20__generate_to_descriptor!();
7777
crate::impl_client_v17__invalidate_block!();
7878

7979
// == Hidden ==
80+
crate::impl_client_v27__add_connection!();
8081
crate::impl_client_v21__add_peer_address!();
8182
crate::impl_client_v17__estimate_raw_fee!();
8283
crate::impl_client_v17__wait_for_block!();

client/src/client_sync/v29/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ crate::impl_client_v20__generate_to_descriptor!();
7777
crate::impl_client_v17__invalidate_block!();
7878

7979
// == Hidden ==
80+
crate::impl_client_v27__add_connection!();
8081
crate::impl_client_v21__add_peer_address!();
8182
crate::impl_client_v17__estimate_raw_fee!();
8283
crate::impl_client_v17__wait_for_block!();

0 commit comments

Comments
 (0)