bitcoind_json_rpc_client/client_sync/v17/
wallet.rs1#[macro_export]
14macro_rules! impl_client_v17__createwallet {
15 () => {
16 impl Client {
17 pub fn create_wallet(&self, wallet: &str) -> Result<CreateWallet> {
18 self.call("createwallet", &[wallet.into()])
19 }
20 }
21 };
22}
23
24#[macro_export]
26macro_rules! impl_client_v17__unloadwallet {
27 () => {
28 impl Client {
29 pub fn unload_wallet(&self, wallet: &str) -> Result<()> {
30 self.call("unloadwallet", &[wallet.into()])
31 }
32 }
33 };
34}
35
36#[macro_export]
38macro_rules! impl_client_v17__loadwallet {
39 () => {
40 impl Client {
41 pub fn load_wallet(&self, wallet: &str) -> Result<LoadWallet> {
42 self.call("loadwallet", &[wallet.into()])
43 }
44 }
45 };
46}
47
48#[macro_export]
50macro_rules! impl_client_v17__getbalance {
51 () => {
52 impl Client {
53 pub fn get_balance(&self) -> Result<GetBalance> { self.call("getbalance", &[]) }
54 }
55 };
56}
57
58#[macro_export]
60macro_rules! impl_client_v17__getnewaddress {
61 () => {
62 impl Client {
63 pub fn new_address(&self) -> Result<bitcoin::Address> {
65 use core::str::FromStr;
66
67 let json = self.get_new_address()?;
68 let address = bitcoin::Address::from_str(&json.0)
69 .expect("assume the address is valid")
70 .assume_checked(); Ok(address)
72 }
73
74 pub fn new_address_with_type(&self, ty: AddressType) -> Result<bitcoin::Address> {
76 use core::str::FromStr;
77
78 let json = self.get_new_address_with_type(ty)?;
79 let address = bitcoin::Address::from_str(&json.0)
80 .expect("assume the address is valid")
81 .assume_checked(); Ok(address)
83 }
84
85 pub fn get_new_address(&self) -> Result<GetNewAddress> {
86 self.call("getnewaddress", &[])
87 }
88
89 pub fn get_new_address_with_type(&self, ty: AddressType) -> Result<GetNewAddress> {
90 self.call("getnewaddress", &["".into(), into_json(ty)?])
91 }
92 }
93 };
94}
95
96#[macro_export]
98macro_rules! impl_client_v17__sendtoaddress {
99 () => {
100 impl Client {
101 pub fn send_to_address(
102 &self,
103 address: &Address<NetworkChecked>,
104 amount: Amount,
105 ) -> Result<SendToAddress> {
106 let mut args = [address.to_string().into(), into_json(amount.to_btc())?];
107 self.call("sendtoaddress", handle_defaults(&mut args, &["".into(), "".into()]))
108 }
109 }
110 };
111}
112
113#[macro_export]
115macro_rules! impl_client_v17__gettransaction {
116 () => {
117 impl Client {
118 pub fn get_transaction(&self, txid: Txid) -> Result<GetTransaction> {
119 self.call("gettransaction", &[into_json(txid)?])
120 }
121 }
122 };
123}