forked from rust-bitcoin/corepc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.rs
More file actions
89 lines (83 loc) · 2.64 KB
/
util.rs
File metadata and controls
89 lines (83 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// SPDX-License-Identifier: CC0-1.0
//! Macros for implementing JSON-RPC methods on a client.
//!
//! Specifically this is methods found under the `== Util ==` section of the
//! API docs of Bitcoin Core `v0.17`.
//!
//! All macros require `Client` to be in scope.
//!
//! See or use the `define_jsonrpc_bitreq_client!` macro to define a `Client`.
/// Implements Bitcoin Core JSON-RPC API method `createmultisig`.
#[macro_export]
macro_rules! impl_client_v17__create_multisig {
() => {
impl Client {
pub fn create_multisig(
&self,
nrequired: u32,
keys: Vec<PublicKey>,
) -> Result<CreateMultisig> {
self.call("createmultisig", &[nrequired.into(), into_json(keys)?])
}
}
};
}
/// Implements Bitcoin Core JSON-RPC API method `estimatesmartfee`.
#[macro_export]
macro_rules! impl_client_v17__estimate_smart_fee {
() => {
impl Client {
pub fn estimate_smart_fee(&self, blocks: u32) -> Result<EstimateSmartFee> {
self.call("estimatesmartfee", &[blocks.into()])
}
}
};
}
/// Implements Bitcoin Core JSON-RPC API method `signmessagewithprivkey`.
#[macro_export]
macro_rules! impl_client_v17__sign_message_with_priv_key {
() => {
impl Client {
pub fn sign_message_with_privkey(
&self,
privkey: &bitcoin::PrivateKey,
message: &str,
) -> Result<SignMessageWithPrivKey> {
self.call("signmessagewithprivkey", &[into_json(privkey)?, message.into()])
}
}
};
}
/// Implements Bitcoin Core JSON-RPC API method `validateaddress`.
#[macro_export]
macro_rules! impl_client_v17__validate_address {
() => {
impl Client {
pub fn validate_address(
&self,
address: &Address<NetworkChecked>,
) -> Result<ValidateAddress> {
self.call("validateaddress", &[address.to_string().into()])
}
}
};
}
/// Implements Bitcoin Core JSON-RPC API method `verifymessage`.
#[macro_export]
macro_rules! impl_client_v17__verify_message {
() => {
impl Client {
pub fn verify_message(
&self,
address: &Address<NetworkChecked>,
signature: &sign_message::MessageSignature,
message: &str,
) -> Result<VerifyMessage> {
self.call(
"verifymessage",
&[address.to_string().into(), signature.to_string().into(), message.into()],
)
}
}
};
}