Skip to content

Commit 09d0f90

Browse files
committed
Merge #233: Implement importprivkey and test
4b4e084 Implement importprivkey and test (GideonBature) Pull request description: The JSON-RPC method `importprivkey` does return null. We want to test this to catch any changes in behavior in future Core versions. This PR adds a client function that errors if the return value is anything other than `null`, along with an integration test that calls this function. Ref: [#116](#116) ACKs for top commit: tcharding: ACK 4b4e084 Tree-SHA512: 9a506b8b250d55099027241c53b2fa169f73cb988e92667c7dcb10ab30f63c14462b6501db40b595129be39a8f1e9d07581e53dcea02154f2249924c013c981c
2 parents 4a61d99 + 4b4e084 commit 09d0f90

File tree

15 files changed

+49
-1
lines changed

15 files changed

+49
-1
lines changed

client/src/client_sync/v17/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ crate::impl_client_v17__get_received_by_address!();
123123
crate::impl_client_v17__get_transaction!();
124124
crate::impl_client_v17__get_unconfirmed_balance!();
125125
crate::impl_client_v17__get_wallet_info!();
126+
crate::impl_client_v17__import_privkey!();
126127
crate::impl_client_v17__list_address_groupings!();
127128
crate::impl_client_v17__list_labels!();
128129
crate::impl_client_v17__list_lock_unspent!();

client/src/client_sync/v17/wallet.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,22 @@ macro_rules! impl_client_v17__get_wallet_info {
243243
};
244244
}
245245

246+
/// Implements Bitcoin Core JSON-RPC API method `importprivkey`.
247+
#[macro_export]
248+
macro_rules! impl_client_v17__import_privkey {
249+
() => {
250+
impl Client {
251+
pub fn import_privkey(&self, privkey: &bitcoin::PrivateKey) -> Result<()> {
252+
match self.call("importprivkey", &[into_json(privkey)?]) {
253+
Ok(serde_json::Value::Null) => Ok(()),
254+
Ok(res) => Err(Error::Returned(res.to_string())),
255+
Err(err) => Err(err.into()),
256+
}
257+
}
258+
}
259+
};
260+
}
261+
246262
/// Implements Bitcoin Core JSON-RPC API method `listaddressgroupings`.
247263
#[macro_export]
248264
macro_rules! impl_client_v17__list_address_groupings {

client/src/client_sync/v18/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ crate::impl_client_v17__get_received_by_address!();
136136
crate::impl_client_v17__get_transaction!();
137137
crate::impl_client_v17__get_unconfirmed_balance!();
138138
crate::impl_client_v17__get_wallet_info!();
139+
crate::impl_client_v17__import_privkey!();
139140
crate::impl_client_v17__list_address_groupings!();
140141
crate::impl_client_v17__list_labels!();
141142
crate::impl_client_v17__list_lock_unspent!();

client/src/client_sync/v19/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ crate::impl_client_v17__get_received_by_address!();
133133
crate::impl_client_v17__get_transaction!();
134134
crate::impl_client_v17__get_unconfirmed_balance!();
135135
crate::impl_client_v17__get_wallet_info!();
136+
crate::impl_client_v17__import_privkey!();
136137
crate::impl_client_v17__list_address_groupings!();
137138
crate::impl_client_v17__list_labels!();
138139
crate::impl_client_v17__list_lock_unspent!();

client/src/client_sync/v20/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ crate::impl_client_v17__get_received_by_address!();
130130
crate::impl_client_v17__get_transaction!();
131131
crate::impl_client_v17__get_unconfirmed_balance!();
132132
crate::impl_client_v17__get_wallet_info!();
133+
crate::impl_client_v17__import_privkey!();
133134
crate::impl_client_v17__list_address_groupings!();
134135
crate::impl_client_v17__list_labels!();
135136
crate::impl_client_v17__list_lock_unspent!();

client/src/client_sync/v21/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ crate::impl_client_v17__get_received_by_address!();
132132
crate::impl_client_v17__get_transaction!();
133133
crate::impl_client_v17__get_unconfirmed_balance!();
134134
crate::impl_client_v17__get_wallet_info!();
135+
crate::impl_client_v17__import_privkey!();
135136
crate::impl_client_v17__list_address_groupings!();
136137
crate::impl_client_v17__list_labels!();
137138
crate::impl_client_v17__list_lock_unspent!();

client/src/client_sync/v22/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ crate::impl_client_v17__get_received_by_address!();
132132
crate::impl_client_v17__get_transaction!();
133133
crate::impl_client_v17__get_unconfirmed_balance!();
134134
crate::impl_client_v17__get_wallet_info!();
135+
crate::impl_client_v17__import_privkey!();
135136
crate::impl_client_v17__list_address_groupings!();
136137
crate::impl_client_v17__list_labels!();
137138
crate::impl_client_v17__list_lock_unspent!();

client/src/client_sync/v23/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ crate::impl_client_v17__get_received_by_address!();
134134
crate::impl_client_v17__get_transaction!();
135135
crate::impl_client_v17__get_unconfirmed_balance!();
136136
crate::impl_client_v17__get_wallet_info!();
137+
crate::impl_client_v17__import_privkey!();
137138
crate::impl_client_v17__list_address_groupings!();
138139
crate::impl_client_v17__list_labels!();
139140
crate::impl_client_v17__list_lock_unspent!();

client/src/client_sync/v24/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ crate::impl_client_v17__get_received_by_address!();
131131
crate::impl_client_v17__get_transaction!();
132132
crate::impl_client_v17__get_unconfirmed_balance!();
133133
crate::impl_client_v17__get_wallet_info!();
134+
crate::impl_client_v17__import_privkey!();
134135
crate::impl_client_v17__list_address_groupings!();
135136
crate::impl_client_v17__list_labels!();
136137
crate::impl_client_v17__list_lock_unspent!();

client/src/client_sync/v25/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ crate::impl_client_v17__get_received_by_address!();
131131
crate::impl_client_v17__get_transaction!();
132132
crate::impl_client_v17__get_unconfirmed_balance!();
133133
crate::impl_client_v17__get_wallet_info!();
134+
crate::impl_client_v17__import_privkey!();
134135
crate::impl_client_v17__list_address_groupings!();
135136
crate::impl_client_v17__list_labels!();
136137
crate::impl_client_v17__list_lock_unspent!();

0 commit comments

Comments
 (0)