Skip to content

Commit da4c0e5

Browse files
committed
Implement version specific types for pubkey
1 parent 7ac5e64 commit da4c0e5

File tree

14 files changed

+82
-0
lines changed

14 files changed

+82
-0
lines changed

client/src/client_sync/v17/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ crate::impl_client_v17__encryptwallet!();
131131
crate::impl_client_v17__importaddress!();
132132
crate::impl_client_v17__importprivkey!();
133133
crate::impl_client_v17__importprunedfunds!();
134+
crate::impl_client_v17__importpubkey!();
134135

135136
/// Argument to the `Client::get_new_address_with_type` function.
136137
///

client/src/client_sync/v17/wallet.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,3 +596,38 @@ macro_rules! impl_client_v17__importprunedfunds {
596596
}
597597
};
598598
}
599+
600+
/// Implements Bitcoin Core JSON-RPC API method `importpubkey`
601+
#[macro_export]
602+
macro_rules! impl_client_v17__importpubkey {
603+
() => {
604+
impl Client {
605+
pub fn import_pubkey(
606+
&self,
607+
pubkey: &PublicKey,
608+
label: Option<&str>,
609+
rescan: Option<bool>,
610+
) -> Result<()> {
611+
let pubkey_hex = pubkey.to_string();
612+
let mut params = vec![pubkey_hex.into()];
613+
614+
if label.is_some() || rescan.is_some() {
615+
params.push(label.map_or(serde_json::Value::String("".into()), |l| l.into()));
616+
}
617+
618+
if let Some(r) = rescan {
619+
params.push(r.into());
620+
}
621+
622+
match self.call("importpubkey", &params) {
623+
Ok(serde_json::Value::Null) => Ok(()),
624+
Ok(ref val) if val.is_null() => Ok(()),
625+
Ok(other) => Err(crate::client_sync::Error::Returned(format!(
626+
"importpubkey expected null, got: {}", other
627+
))),
628+
Err(e) => Err(e.into()),
629+
}
630+
}
631+
}
632+
};
633+
}

client/src/client_sync/v18/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,4 @@ crate::impl_client_v17__encryptwallet!();
124124
crate::impl_client_v17__importaddress!();
125125
crate::impl_client_v17__importprivkey!();
126126
crate::impl_client_v17__importprunedfunds!();
127+
crate::impl_client_v17__importpubkey!();

client/src/client_sync/v19/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,4 @@ crate::impl_client_v17__encryptwallet!();
126126
crate::impl_client_v17__importaddress!();
127127
crate::impl_client_v17__importprivkey!();
128128
crate::impl_client_v17__importprunedfunds!();
129+
crate::impl_client_v17__importpubkey!();

client/src/client_sync/v20/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,4 @@ crate::impl_client_v20__encryptwallet!();
125125
crate::impl_client_v17__importaddress!();
126126
crate::impl_client_v17__importprivkey!();
127127
crate::impl_client_v17__importprunedfunds!();
128+
crate::impl_client_v17__importpubkey!();

client/src/client_sync/v21/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,4 @@ crate::impl_client_v20__encryptwallet!();
125125
crate::impl_client_v17__importaddress!();
126126
crate::impl_client_v17__importprivkey!();
127127
crate::impl_client_v17__importprunedfunds!();
128+
crate::impl_client_v17__importpubkey!();

client/src/client_sync/v22/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,4 @@ crate::impl_client_v20__encryptwallet!();
126126
crate::impl_client_v17__importaddress!();
127127
crate::impl_client_v17__importprivkey!();
128128
crate::impl_client_v17__importprunedfunds!();
129+
crate::impl_client_v17__importpubkey!();

client/src/client_sync/v23/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ crate::impl_client_v20__encryptwallet!();
127127
crate::impl_client_v17__importaddress!();
128128
crate::impl_client_v17__importprivkey!();
129129
crate::impl_client_v17__importprunedfunds!();
130+
crate::impl_client_v17__importpubkey!();
130131

131132
/// Argument to the `Client::get_new_address_with_type` function.
132133
///

client/src/client_sync/v24.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,4 @@ crate::impl_client_v20__encryptwallet!();
123123
crate::impl_client_v17__importaddress!();
124124
crate::impl_client_v17__importprivkey!();
125125
crate::impl_client_v17__importprunedfunds!();
126+
crate::impl_client_v17__importpubkey!();

client/src/client_sync/v25.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,4 @@ crate::impl_client_v20__encryptwallet!();
123123
crate::impl_client_v17__importaddress!();
124124
crate::impl_client_v17__importprivkey!();
125125
crate::impl_client_v17__importprunedfunds!();
126+
crate::impl_client_v17__importpubkey!();

0 commit comments

Comments
 (0)