Skip to content

Commit 4b4e084

Browse files
committed
Implement importprivkey and test
1 parent 47caf92 commit 4b4e084

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
@@ -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/v19/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/v20/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ crate::impl_client_v17__get_received_by_address!();
129129
crate::impl_client_v17__get_transaction!();
130130
crate::impl_client_v17__get_unconfirmed_balance!();
131131
crate::impl_client_v17__get_wallet_info!();
132+
crate::impl_client_v17__import_privkey!();
132133
crate::impl_client_v17__list_address_groupings!();
133134
crate::impl_client_v17__list_labels!();
134135
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
@@ -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/v22/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/v23/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/v24/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/v25/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!();

0 commit comments

Comments
 (0)