corepc_client/client_sync/v17/
wallet.rs

1// SPDX-License-Identifier: CC0-1.0
2
3//! Macros for implementing JSON-RPC methods on a client.
4//!
5//! Specifically this is methods found under the `== Wallet ==` section of the
6//! API docs of Bitcoin Core `v0.17`.
7//!
8//! All macros require `Client` to be in scope.
9//!
10//! See or use the `define_jsonrpc_minreq_client!` macro to define a `Client`.
11
12/// Implements Bitcoin Core JSON-RPC API method `abandontransaction`.
13#[macro_export]
14macro_rules! impl_client_v17__abandon_transaction {
15    () => {
16        impl Client {
17            pub fn abandon_transaction(&self, txid: Txid) -> Result<()> {
18                match self.call("abandontransaction", &[into_json(txid)?]) {
19                    Ok(serde_json::Value::Null) => Ok(()),
20                    Ok(res) => Err(Error::Returned(res.to_string())),
21                    Err(err) => Err(err.into()),
22                }
23            }
24        }
25    };
26}
27
28/// Implements Bitcoin Core JSON-RPC API method `abortrescan`.
29#[macro_export]
30macro_rules! impl_client_v17__abort_rescan {
31    () => {
32        impl Client {
33            pub fn abort_rescan(&self) -> Result<AbortRescan> { self.call("abortrescan", &[]) }
34        }
35    };
36}
37
38/// Implements Bitcoin Core JSON-RPC API method `addmultisigaddress`.
39#[macro_export]
40macro_rules! impl_client_v17__add_multisig_address {
41    () => {
42        impl Client {
43            pub fn add_multisig_address_with_keys(
44                &self,
45                nrequired: u32,
46                keys: Vec<PublicKey>,
47            ) -> Result<AddMultisigAddress> {
48                self.call("addmultisigaddress", &[nrequired.into(), into_json(keys)?])
49            }
50
51            pub fn add_multisig_address_with_addresses(
52                &self,
53                nrequired: u32,
54                keys: Vec<Address>,
55            ) -> Result<AddMultisigAddress> {
56                self.call("addmultisigaddress", &[nrequired.into(), into_json(keys)?])
57            }
58        }
59    };
60}
61
62/// Implements Bitcoin Core JSON-RPC API method `bumpfee`.
63#[macro_export]
64macro_rules! impl_client_v17__backup_wallet {
65    () => {
66        impl Client {
67            pub fn backup_wallet(&self, destination: &Path) -> Result<()> {
68                match self.call("backupwallet", &[into_json(destination)?]) {
69                    Ok(serde_json::Value::Null) => Ok(()),
70                    Ok(res) => Err(Error::Returned(res.to_string())),
71                    Err(err) => Err(err.into()),
72                }
73            }
74        }
75    };
76}
77
78/// Implements Bitcoin Core JSON-RPC API method `bumpfee`.
79#[macro_export]
80macro_rules! impl_client_v17__bump_fee {
81    () => {
82        impl Client {
83            pub fn bump_fee(&self, txid: Txid) -> Result<BumpFee> {
84                self.call("bumpfee", &[into_json(txid)?])
85            }
86        }
87    };
88}
89
90/// Implements Bitcoin Core JSON-RPC API method `createwallet`.
91#[macro_export]
92macro_rules! impl_client_v17__create_wallet {
93    () => {
94        impl Client {
95            pub fn create_wallet(&self, wallet: &str) -> Result<CreateWallet> {
96                self.call("createwallet", &[wallet.into()])
97            }
98        }
99    };
100}
101
102/// Implements Bitcoin Core JSON-RPC API method `dumpprivkey`.
103#[macro_export]
104macro_rules! impl_client_v17__dump_priv_key {
105    () => {
106        impl Client {
107            pub fn dump_priv_key(&self, address: &Address) -> Result<DumpPrivKey> {
108                self.call("dumpprivkey", &[into_json(address)?])
109            }
110        }
111    };
112}
113
114/// Implements Bitcoin Core JSON-RPC API method `dumpwallet`.
115#[macro_export]
116macro_rules! impl_client_v17__dump_wallet {
117    () => {
118        impl Client {
119            // filename is either absolute or relative to bitcoind.
120            pub fn dump_wallet(&self, filename: &Path) -> Result<DumpWallet> {
121                self.call("dumpwallet", &[into_json(filename)?])
122            }
123        }
124    };
125}
126
127/// Implements Bitcoin Core JSON-RPC API method `encryptwallet`.
128#[macro_export]
129macro_rules! impl_client_v17__encrypt_wallet {
130    () => {
131        impl Client {
132            // filename is either absolute or relative to bitcoind.
133            pub fn encrypt_wallet(&self, passphrase: &str) -> Result<EncryptWallet> {
134                self.call("encryptwallet", &[into_json(passphrase)?])
135            }
136        }
137    };
138}
139
140/// Implements Bitcoin Core JSON-RPC API method `getaddressesbylabel`.
141#[macro_export]
142macro_rules! impl_client_v17__get_addresses_by_label {
143    () => {
144        impl Client {
145            pub fn get_addresses_by_label(&self, label: &str) -> Result<GetAddressesByLabel> {
146                self.call("getaddressesbylabel", &[label.into()])
147            }
148        }
149    };
150}
151
152/// Implements Bitcoin Core JSON-RPC API method `getaddressinfo`.
153#[macro_export]
154macro_rules! impl_client_v17__get_address_info {
155    () => {
156        impl Client {
157            pub fn get_address_info(&self, address: &Address) -> Result<GetAddressInfo> {
158                self.call("getaddressinfo", &[into_json(address)?])
159            }
160        }
161    };
162}
163
164/// Implements Bitcoin Core JSON-RPC API method `getbalance`.
165#[macro_export]
166macro_rules! impl_client_v17__get_balance {
167    () => {
168        impl Client {
169            pub fn get_balance(&self) -> Result<GetBalance> { self.call("getbalance", &[]) }
170        }
171    };
172}
173
174/// Implements Bitcoin Core JSON-RPC API method `getnewaddress`.
175#[macro_export]
176macro_rules! impl_client_v17__get_new_address {
177    () => {
178        impl Client {
179            /// Gets a new address from `bitcoind` and parses it assuming its correct.
180            pub fn new_address(&self) -> Result<bitcoin::Address> {
181                let json = self.get_new_address(None, None)?;
182                let model = json.into_model().unwrap();
183                Ok(model.0.assume_checked())
184            }
185
186            /// Gets a new address from `bitcoind` and parses it assuming its correct.
187            pub fn new_address_with_type(&self, ty: AddressType) -> Result<bitcoin::Address> {
188                let json = self.get_new_address(None, Some(ty))?;
189                let model = json.into_model().unwrap();
190                Ok(model.0.assume_checked())
191            }
192
193            /// Gets a new address with label from `bitcoind` and parses it assuming its correct.
194            // FIXME: unchecked network here is ugly and not uniform with other functions.
195            pub fn new_address_with_label(
196                &self,
197                label: &str,
198            ) -> Result<bitcoin::Address<bitcoin::address::NetworkUnchecked>> {
199                let json = self.get_new_address(Some(label), None)?;
200                let model = json.into_model().unwrap();
201                Ok(model.0)
202            }
203
204            /// Gets a new address - low level RPC call.
205            pub fn get_new_address(
206                &self,
207                label: Option<&str>,
208                ty: Option<AddressType>,
209            ) -> Result<GetNewAddress> {
210                match (label, ty) {
211                    (Some(label), Some(ty)) =>
212                        self.call("getnewaddress", &[into_json(label)?, into_json(ty)?]),
213                    (Some(label), None) => self.call("getnewaddress", &[into_json(label)?]),
214                    (None, Some(ty)) => self.call("getnewaddress", &["".into(), into_json(ty)?]),
215                    (None, None) => self.call("getnewaddress", &[]),
216                }
217            }
218        }
219    };
220}
221
222/// Implements Bitcoin Core JSON-RPC API method `getrawchangeaddress`.
223#[macro_export]
224macro_rules! impl_client_v17__get_raw_change_address {
225    () => {
226        impl Client {
227            pub fn get_raw_change_address(&self) -> Result<GetRawChangeAddress> {
228                self.call("getrawchangeaddress", &[])
229            }
230        }
231    };
232}
233
234/// Implements Bitcoin Core JSON-RPC API method `getreceivedbyaddress`.
235#[macro_export]
236macro_rules! impl_client_v17__get_received_by_address {
237    () => {
238        impl Client {
239            pub fn get_received_by_address(
240                &self,
241                address: &Address<NetworkChecked>,
242            ) -> Result<GetReceivedByAddress> {
243                self.call("getreceivedbyaddress", &[address.to_string().into()])
244            }
245        }
246    };
247}
248
249/// Implements Bitcoin Core JSON-RPC API method `gettransaction`.
250#[macro_export]
251macro_rules! impl_client_v17__get_transaction {
252    () => {
253        impl Client {
254            pub fn get_transaction(&self, txid: Txid) -> Result<GetTransaction> {
255                self.call("gettransaction", &[into_json(txid)?])
256            }
257        }
258    };
259}
260
261/// Implements Bitcoin Core JSON-RPC API method `getunconfirmedbalance`.
262#[macro_export]
263macro_rules! impl_client_v17__get_unconfirmed_balance {
264    () => {
265        impl Client {
266            pub fn get_unconfirmed_balance(&self) -> Result<GetUnconfirmedBalance> {
267                self.call("getunconfirmedbalance", &[])
268            }
269        }
270    };
271}
272
273/// Implements Bitcoin Core JSON-RPC API method `getwalletinfo`.
274#[macro_export]
275macro_rules! impl_client_v17__get_wallet_info {
276    () => {
277        impl Client {
278            pub fn get_wallet_info(&self) -> Result<GetWalletInfo> {
279                self.call("getwalletinfo", &[])
280            }
281        }
282    };
283}
284
285/// Implements Bitcoin Core JSON-RPC API method `importaddress`.
286#[macro_export]
287macro_rules! impl_client_v17__import_address {
288    () => {
289        impl Client {
290            pub fn import_address(&self, address: &Address) -> Result<()> {
291                match self.call("importaddress", &[into_json(address)?]) {
292                    Ok(serde_json::Value::Null) => Ok(()),
293                    Ok(res) => Err(Error::Returned(res.to_string())),
294                    Err(err) => Err(err.into()),
295                }
296            }
297        }
298    };
299}
300
301/// Implements Bitcoin Core JSON-RPC API method `importmulti`.
302#[macro_export]
303macro_rules! impl_client_v17__import_multi {
304    () => {
305        impl Client {
306            pub fn import_multi(&self, requests: &[ImportMultiRequest]) -> Result<ImportMulti> {
307                self.call("importmulti", &[into_json(requests)?])
308            }
309        }
310    };
311}
312
313/// Implements Bitcoin Core JSON-RPC API method `importprivkey`.
314#[macro_export]
315macro_rules! impl_client_v17__import_privkey {
316    () => {
317        impl Client {
318            pub fn import_privkey(&self, privkey: &bitcoin::PrivateKey) -> Result<()> {
319                match self.call("importprivkey", &[into_json(privkey)?]) {
320                    Ok(serde_json::Value::Null) => Ok(()),
321                    Ok(res) => Err(Error::Returned(res.to_string())),
322                    Err(err) => Err(err.into()),
323                }
324            }
325        }
326    };
327}
328
329/// Implements Bitcoin Core JSON-RPC API method `importprunedfunds`.
330#[macro_export]
331macro_rules! impl_client_v17__import_pruned_funds {
332    () => {
333        impl Client {
334            pub fn import_pruned_funds(
335                &self,
336                raw_transaction: &str,
337                tx_out_proof: &str,
338            ) -> Result<()> {
339                match self.call(
340                    "importprunedfunds",
341                    &[into_json(raw_transaction)?, into_json(tx_out_proof)?],
342                ) {
343                    Ok(serde_json::Value::Null) => Ok(()),
344                    Ok(res) => Err(Error::Returned(res.to_string())),
345                    Err(err) => Err(err.into()),
346                }
347            }
348        }
349    };
350}
351
352/// Implements Bitcoin Core JSON-RPC API method `importpubkey`.
353#[macro_export]
354macro_rules! impl_client_v17__import_pubkey {
355    () => {
356        impl Client {
357            pub fn import_pubkey(&self, pubkey: &bitcoin::PublicKey) -> Result<()> {
358                match self.call("importpubkey", &[into_json(pubkey)?]) {
359                    Ok(serde_json::Value::Null) => Ok(()),
360                    Ok(res) => Err(Error::Returned(res.to_string())),
361                    Err(err) => Err(err.into()),
362                }
363            }
364        }
365    };
366}
367
368/// Implements Bitcoin Core JSON-RPC API method `importwallet`.
369#[macro_export]
370macro_rules! impl_client_v17__import_wallet {
371    () => {
372        impl Client {
373            pub fn import_wallet(&self, filename: &Path) -> Result<()> {
374                match self.call("importwallet", &[into_json(filename)?]) {
375                    Ok(serde_json::Value::Null) => Ok(()),
376                    Ok(res) => Err(Error::Returned(res.to_string())),
377                    Err(err) => Err(err.into()),
378                }
379            }
380        }
381    };
382}
383
384/// Implements Bitcoin Core JSON-RPC API method `keypoolrefill`.
385#[macro_export]
386macro_rules! impl_client_v17__key_pool_refill {
387    () => {
388        impl Client {
389            pub fn key_pool_refill(&self) -> Result<()> {
390                match self.call("keypoolrefill", &[]) {
391                    Ok(serde_json::Value::Null) => Ok(()),
392                    Ok(res) => Err(Error::Returned(res.to_string())),
393                    Err(err) => Err(err.into()),
394                }
395            }
396        }
397    };
398}
399
400/// Implements Bitcoin Core JSON-RPC API method `listaddressgroupings`.
401#[macro_export]
402macro_rules! impl_client_v17__list_address_groupings {
403    () => {
404        impl Client {
405            pub fn list_address_groupings(&self) -> Result<ListAddressGroupings> {
406                self.call("listaddressgroupings", &[])
407            }
408        }
409    };
410}
411
412/// Implements Bitcoin Core JSON-RPC API method `listlabels`.
413#[macro_export]
414macro_rules! impl_client_v17__list_labels {
415    () => {
416        impl Client {
417            pub fn list_labels(&self) -> Result<ListLabels> { self.call("listlabels", &[]) }
418        }
419    };
420}
421
422/// Implements Bitcoin Core JSON-RPC API method `listlockunspent`.
423#[macro_export]
424macro_rules! impl_client_v17__list_lock_unspent {
425    () => {
426        impl Client {
427            pub fn list_lock_unspent(&self) -> Result<ListLockUnspent> {
428                self.call("listlockunspent", &[])
429            }
430        }
431    };
432}
433
434/// Implements Bitcoin Core JSON-RPC API method `listreceivedbyaddress`.
435#[macro_export]
436macro_rules! impl_client_v17__list_received_by_address {
437    () => {
438        impl Client {
439            pub fn list_received_by_address(&self) -> Result<ListReceivedByAddress> {
440                self.call("listreceivedbyaddress", &[])
441            }
442        }
443    };
444}
445
446/// Implements Bitcoin Core JSON-RPC API method `listsinceblock`.
447#[macro_export]
448macro_rules! impl_client_v17__list_since_block {
449    () => {
450        impl Client {
451            pub fn list_since_block(&self) -> Result<ListSinceBlock> {
452                self.call("listsinceblock", &[])
453            }
454        }
455    };
456}
457
458/// Implements Bitcoin Core JSON-RPC API method `listtransactions`.
459#[macro_export]
460macro_rules! impl_client_v17__list_transactions {
461    () => {
462        impl Client {
463            pub fn list_transactions(&self) -> Result<ListTransactions> {
464                self.call("listtransactions", &[])
465            }
466        }
467    };
468}
469
470/// Implements Bitcoin Core JSON-RPC API method `listunspent`.
471#[macro_export]
472macro_rules! impl_client_v17__list_unspent {
473    () => {
474        impl Client {
475            pub fn list_unspent(&self) -> Result<ListUnspent> { self.call("listunspent", &[]) }
476        }
477    };
478}
479
480/// Implements Bitcoin Core JSON-RPC API method `listwallets`.
481#[macro_export]
482macro_rules! impl_client_v17__list_wallets {
483    () => {
484        impl Client {
485            pub fn list_wallets(&self) -> Result<ListWallets> { self.call("listwallets", &[]) }
486        }
487    };
488}
489
490/// Implements Bitcoin Core JSON-RPC API method `loadwallet`.
491#[macro_export]
492macro_rules! impl_client_v17__load_wallet {
493    () => {
494        impl Client {
495            pub fn load_wallet(&self, filename: &str) -> Result<LoadWallet> {
496                self.call("loadwallet", &[into_json(filename)?])
497            }
498        }
499    };
500}
501
502/// Implements Bitcoin Core JSON-RPC API method `lockunspent`.
503#[macro_export]
504macro_rules! impl_client_v17__lock_unspent {
505    () => {
506        impl Client {
507            /// Lock the given list of transaction outputs. Returns true on success.
508            ///
509            /// This wraps Core RPC: `lockunspent false [{"txid":"..","vout":n},...]`.
510            pub fn lock_unspent(&self, outputs: &[(Txid, u32)]) -> Result<LockUnspent> {
511                let outs: Vec<_> = outputs
512                    .iter()
513                    .map(|(txid, vout)| serde_json::json!({"txid": txid, "vout": vout}))
514                    .collect();
515                self.call("lockunspent", &[into_json(false)?, outs.into()])
516            }
517
518            /// Unlock the given list of transaction outputs. Returns true on success.
519            ///
520            /// This wraps Core RPC: `lockunspent true [{"txid":"..","vout":n},...]`.
521            pub fn unlock_unspent(&self, outputs: &[(Txid, u32)]) -> Result<LockUnspent> {
522                let outs: Vec<_> = outputs
523                    .iter()
524                    .map(|(txid, vout)| serde_json::json!({"txid": txid, "vout": vout}))
525                    .collect();
526                self.call("lockunspent", &[into_json(true)?, outs.into()])
527            }
528        }
529    };
530}
531
532/// Implements Bitcoin Core JSON-RPC API method `removeprunedfunds`.
533#[macro_export]
534macro_rules! impl_client_v17__remove_pruned_funds {
535    () => {
536        impl Client {
537            pub fn remove_pruned_funds(&self, txid: Txid) -> Result<()> {
538                self.call("removeprunedfunds", &[into_json(txid)?])
539            }
540        }
541    };
542}
543
544/// Implements Bitcoin Core JSON-RPC API method `rescanblockchain`.
545#[macro_export]
546macro_rules! impl_client_v17__rescan_blockchain {
547    () => {
548        impl Client {
549            pub fn rescan_blockchain(&self) -> Result<RescanBlockchain> {
550                self.call("rescanblockchain", &[])
551            }
552        }
553    };
554}
555
556/// Implements Bitcoin Core JSON-RPC API method `sendmany`.
557#[macro_export]
558macro_rules! impl_client_v17__send_many {
559    () => {
560        impl Client {
561            pub fn send_many(&self, amounts: BTreeMap<Address, Amount>) -> Result<SendMany> {
562                let dummy = ""; // Must be set to "" for backwards compatibility.
563                let amount_btc: BTreeMap<String, f64> = amounts
564                    .into_iter()
565                    .map(|(addr, amount)| (addr.to_string(), amount.to_btc()))
566                    .collect();
567                self.call("sendmany", &[into_json(dummy)?, into_json(amount_btc)?])
568            }
569        }
570    };
571}
572
573/// Implements Bitcoin Core JSON-RPC API method `sendtoaddress`.
574#[macro_export]
575macro_rules! impl_client_v17__send_to_address {
576    () => {
577        impl Client {
578            // Send to address - no RBF.
579            pub fn send_to_address(
580                &self,
581                address: &Address<NetworkChecked>,
582                amount: Amount,
583            ) -> Result<SendToAddress> {
584                let args = [address.to_string().into(), into_json(amount.to_btc())?];
585                self.call("sendtoaddress", &args)
586            }
587
588            // Send to address - with RBF.
589            pub fn send_to_address_rbf(
590                &self,
591                address: &Address<NetworkChecked>,
592                amount: Amount,
593            ) -> Result<SendToAddress> {
594                let comment = "";
595                let comment_to = "";
596                let subtract_fee_from_amount = false;
597                let replaceable = true;
598
599                let args = [
600                    address.to_string().into(),
601                    into_json(amount.to_btc())?,
602                    comment.into(),
603                    comment_to.into(),
604                    subtract_fee_from_amount.into(),
605                    replaceable.into(),
606                ];
607                self.call("sendtoaddress", &args)
608            }
609        }
610    };
611}
612
613/// Implements Bitcoin Core JSON-RPC API method `sethdseed`.
614#[macro_export]
615macro_rules! impl_client_v17__set_hd_seed {
616    () => {
617        impl Client {
618            pub fn set_hd_seed(&self) -> Result<()> {
619                match self.call("sethdseed", &[]) {
620                    Ok(serde_json::Value::Null) => Ok(()),
621                    Ok(res) => Err(Error::Returned(res.to_string())),
622                    Err(err) => Err(err.into()),
623                }
624            }
625        }
626    };
627}
628
629/// Implements Bitcoin Core JSON-RPC API method `settxfee`.
630#[macro_export]
631macro_rules! impl_client_v17__set_tx_fee {
632    () => {
633        impl Client {
634            pub fn set_tx_fee(&self, fee_rate: bitcoin::FeeRate) -> Result<SetTxFee> {
635                let fee_rate_btc_kvb = fee_rate.to_sat_per_vb_floor() as f64 / 100_000.0;
636                self.call("settxfee", &[fee_rate_btc_kvb.into()])
637            }
638        }
639    };
640}
641
642/// Implements Bitcoin Core JSON-RPC API method `signmessage`.
643#[macro_export]
644macro_rules! impl_client_v17__sign_message {
645    () => {
646        impl Client {
647            pub fn sign_message(&self, address: &Address, message: &str) -> Result<SignMessage> {
648                self.call("signmessage", &[into_json(address)?, into_json(message)?])
649            }
650        }
651    };
652}
653
654/// Implements Bitcoin Core JSON-RPC API method `signrawtransactionwithwallet`.
655#[macro_export]
656macro_rules! impl_client_v17__sign_raw_transaction_with_wallet {
657    () => {
658        impl Client {
659            // `hexstring`: The transaction hex string.
660            pub fn sign_raw_transaction_with_wallet(
661                &self,
662                tx: &bitcoin::Transaction,
663            ) -> Result<SignRawTransactionWithWallet> {
664                let hex = bitcoin::consensus::encode::serialize_hex(tx);
665                self.call("signrawtransactionwithwallet", &[into_json(hex)?])
666            }
667        }
668    };
669}
670
671/// Implements Bitcoin Core JSON-RPC API method `unloadwallet`.
672#[macro_export]
673macro_rules! impl_client_v17__unload_wallet {
674    () => {
675        impl Client {
676            pub fn unload_wallet(&self, wallet_name: &str) -> Result<()> {
677                match self.call("unloadwallet", &[into_json(wallet_name)?]) {
678                    Ok(serde_json::Value::Null) => Ok(()),
679                    Ok(res) => Err(Error::Returned(res.to_string())),
680                    Err(err) => Err(err.into()),
681                }
682            }
683        }
684    };
685}
686
687/// Implements Bitcoin Core JSON-RPC API method `walletpassphrase`.
688#[macro_export]
689macro_rules! impl_client_v17__wallet_passphrase {
690    () => {
691        impl Client {
692            pub fn wallet_passphrase(&self, passphrase: &str, timeout: u64) -> Result<()> {
693                match self.call("walletpassphrase", &[passphrase.into(), timeout.into()]) {
694                    Ok(serde_json::Value::Null) => Ok(()),
695                    Ok(res) => Err(Error::Returned(res.to_string())),
696                    Err(err) => Err(err.into()),
697                }
698            }
699        }
700    };
701}
702
703/// Implements Bitcoin Core JSON-RPC API method `walletcreatefundedpsbt`.
704#[macro_export]
705macro_rules! impl_client_v17__wallet_create_funded_psbt {
706    () => {
707        impl Client {
708            pub fn wallet_create_funded_psbt(
709                &self,
710                inputs: Vec<WalletCreateFundedPsbtInput>,
711                outputs: Vec<BTreeMap<Address, Amount>>,
712            ) -> Result<WalletCreateFundedPsbt> {
713                // Convert outputs: Vec<BTreeMap<Address, Amount>> to Vec<BTreeMap<String, f64>>
714                let outputs_json: Vec<_> = outputs
715                    .into_iter()
716                    .map(|map| {
717                        map.into_iter()
718                            .map(|(addr, amt)| (addr.to_string(), amt.to_btc()))
719                            .collect::<BTreeMap<_, _>>()
720                    })
721                    .collect();
722                self.call("walletcreatefundedpsbt", &[into_json(inputs)?, into_json(outputs_json)?])
723            }
724        }
725    };
726}
727
728/// Implements Bitcoin Core JSON-RPC API method `walletlock`.
729#[macro_export]
730macro_rules! impl_client_v17__wallet_lock {
731    () => {
732        impl Client {
733            pub fn wallet_lock(&self) -> Result<()> {
734                match self.call("walletlock", &[]) {
735                    Ok(serde_json::Value::Null) => Ok(()),
736                    Ok(res) => Err(Error::Returned(res.to_string())),
737                    Err(err) => Err(err.into()),
738                }
739            }
740        }
741    };
742}
743
744/// Implements Bitcoin Core JSON-RPC API method `walletpassphrasechange`.
745#[macro_export]
746macro_rules! impl_client_v17__wallet_passphrase_change {
747    () => {
748        impl Client {
749            pub fn wallet_passphrase_change(
750                &self,
751                old_passphrase: &str,
752                new_passphrase: &str,
753            ) -> Result<()> {
754                match self
755                    .call("walletpassphrasechange", &[old_passphrase.into(), new_passphrase.into()])
756                {
757                    Ok(serde_json::Value::Null) => Ok(()),
758                    Ok(res) => Err(Error::Returned(res.to_string())),
759                    Err(err) => Err(err.into()),
760                }
761            }
762        }
763    };
764}
765
766/// Implements Bitcoin Core JSON-RPC API method `walletprocesspsbt`.
767#[macro_export]
768macro_rules! impl_client_v17__wallet_process_psbt {
769    () => {
770        impl Client {
771            pub fn wallet_process_psbt(&self, psbt: &bitcoin::Psbt) -> Result<WalletProcessPsbt> {
772                // Core expects the PSBT as a base64 string argument (same representation
773                // used by `finalizepsbt`). Serializing the struct with `into_json` produced
774                // an object which Core rejected ("Expected type string, got object").
775                let psbt = format!("{}", psbt);
776                self.call("walletprocesspsbt", &[psbt.into()])
777            }
778        }
779    };
780}