Skip to content

Commit 869f0c4

Browse files
committed
Add newkeypool macro and test
newkeypool returns null. Add a client macro and test to check that it does. Update the types table to say it returns nothing.
1 parent 5429040 commit 869f0c4

File tree

16 files changed

+44
-7
lines changed

16 files changed

+44
-7
lines changed

client/src/client_sync/v23/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ crate::impl_client_v18__list_wallet_dir!();
169169
crate::impl_client_v17__list_wallets!();
170170
crate::impl_client_v22__load_wallet!();
171171
crate::impl_client_v17__lock_unspent!();
172+
crate::impl_client_v23__new_keypool!();
172173
crate::impl_client_v21__psbt_bump_fee!();
173174
crate::impl_client_v17__remove_pruned_funds!();
174175
crate::impl_client_v17__rescan_blockchain!();

client/src/client_sync/v23/wallet.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,28 @@ macro_rules! impl_client_v23__create_wallet {
5757
};
5858
}
5959

60+
/// Implements Bitcoin Core JSON-RPC API method `newkeypool`.
61+
#[macro_export]
62+
macro_rules! impl_client_v23__new_keypool {
63+
() => {
64+
impl Client {
65+
/// Calls `newkeypool` for the loaded wallet.
66+
///
67+
/// > newkeypool
68+
/// >
69+
/// > Entirely clears and refills the keypool.
70+
/// > Requires wallet passphrase to be set if wallet is encrypted.
71+
pub fn new_keypool(&self) -> Result<()> {
72+
match self.call("newkeypool", &[]) {
73+
Ok(serde_json::Value::Null) => Ok(()),
74+
Ok(res) => Err(Error::Returned(res.to_string())),
75+
Err(err) => Err(err.into()),
76+
}
77+
}
78+
}
79+
};
80+
}
81+
6082
/// Implements Bitcoin Core JSON-RPC API method `restorewallet`.
6183
#[macro_export]
6284
macro_rules! impl_client_v23__restore_wallet {

client/src/client_sync/v24/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ crate::impl_client_v18__list_wallet_dir!();
166166
crate::impl_client_v17__list_wallets!();
167167
crate::impl_client_v22__load_wallet!();
168168
crate::impl_client_v17__lock_unspent!();
169+
crate::impl_client_v23__new_keypool!();
169170
crate::impl_client_v21__psbt_bump_fee!();
170171
crate::impl_client_v17__remove_pruned_funds!();
171172
crate::impl_client_v17__rescan_blockchain!();

client/src/client_sync/v25/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ crate::impl_client_v18__list_wallet_dir!();
168168
crate::impl_client_v17__list_wallets!();
169169
crate::impl_client_v22__load_wallet!();
170170
crate::impl_client_v17__lock_unspent!();
171+
crate::impl_client_v23__new_keypool!();
171172
crate::impl_client_v21__psbt_bump_fee!();
172173
crate::impl_client_v17__remove_pruned_funds!();
173174
crate::impl_client_v17__rescan_blockchain!();

client/src/client_sync/v26/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ crate::impl_client_v18__list_wallet_dir!();
172172
crate::impl_client_v17__list_wallets!();
173173
crate::impl_client_v22__load_wallet!();
174174
crate::impl_client_v17__lock_unspent!();
175+
crate::impl_client_v23__new_keypool!();
175176
crate::impl_client_v21__psbt_bump_fee!();
176177
crate::impl_client_v17__remove_pruned_funds!();
177178
crate::impl_client_v17__rescan_blockchain!();

client/src/client_sync/v27/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ crate::impl_client_v18__list_wallet_dir!();
168168
crate::impl_client_v17__list_wallets!();
169169
crate::impl_client_v22__load_wallet!();
170170
crate::impl_client_v17__lock_unspent!();
171+
crate::impl_client_v23__new_keypool!();
171172
crate::impl_client_v21__psbt_bump_fee!();
172173
crate::impl_client_v17__remove_pruned_funds!();
173174
crate::impl_client_v17__rescan_blockchain!();

client/src/client_sync/v28/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ crate::impl_client_v18__list_wallet_dir!();
170170
crate::impl_client_v17__list_wallets!();
171171
crate::impl_client_v22__load_wallet!();
172172
crate::impl_client_v17__lock_unspent!();
173+
crate::impl_client_v23__new_keypool!();
173174
crate::impl_client_v21__psbt_bump_fee!();
174175
crate::impl_client_v17__remove_pruned_funds!();
175176
crate::impl_client_v17__rescan_blockchain!();

client/src/client_sync/v29/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ crate::impl_client_v18__list_wallet_dir!();
170170
crate::impl_client_v17__list_wallets!();
171171
crate::impl_client_v22__load_wallet!();
172172
crate::impl_client_v17__lock_unspent!();
173+
crate::impl_client_v23__new_keypool!();
173174
crate::impl_client_v21__psbt_bump_fee!();
174175
crate::impl_client_v17__remove_pruned_funds!();
175176
crate::impl_client_v17__rescan_blockchain!();

integration_test/tests/wallet.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,14 @@ fn wallet__lock_unspent() {
573573
assert!(json.0);
574574
}
575575

576+
#[cfg(not(feature = "v22_and_below"))]
577+
#[test]
578+
fn wallet__new_keypool() {
579+
let node = Node::with_wallet(Wallet::None, &["-deprecatedrpc=create_bdb"]);
580+
node.client.create_legacy_wallet("legacy_wallet").expect("createlegacywallet");
581+
let _: () = node.client.new_keypool().expect("newkeypool");
582+
}
583+
576584
#[cfg(not(feature = "v20_and_below"))]
577585
#[test]
578586
fn wallet__psbt_bump_fee__modelled() {

types/src/v23/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
//! | listdescriptors | version | |
193193
//! | listlabels | version + model | UNTESTED |
194194
//! | listlockunspent | version + model | UNTESTED |
195-
//! | newkeypool | version + model | TODO |
195+
//! | newkeypool | returns nothing | |
196196
//! | psbtbumpfee | version + model | |
197197
//! | listreceivedbyaddress | version + model | UNTESTED |
198198
//! | listreceivedbylabel | version + model | |

0 commit comments

Comments
 (0)