bitcoin_rpc_midas/transport/
batch_builder.rs

1use std::sync::Arc;
2
3use serde::Deserialize;
4use serde_json::{json, Value};
5
6use crate::responses::*;
7use crate::transport::{BatchTransport, TransportError, TransportTrait};
8/// Typed results for a JSON-RPC batch
9#[derive(Debug, Deserialize)]
10pub struct BatchResults {
11    pub abandontransaction: (),
12    pub abortrescan: Option<AbortrescanResponse>,
13    pub addconnection: Option<AddconnectionResponse>,
14    pub addnode: (),
15    pub addpeeraddress: Option<AddpeeraddressResponse>,
16    pub analyzepsbt: Option<AnalyzepsbtResponse>,
17    pub backupwallet: (),
18    pub bumpfee: Option<BumpfeeResponse>,
19    pub clearbanned: (),
20    pub combinepsbt: Option<CombinepsbtResponse>,
21    pub combinerawtransaction: Option<CombinerawtransactionResponse>,
22    pub converttopsbt: Option<ConverttopsbtResponse>,
23    pub createmultisig: Option<CreatemultisigResponse>,
24    pub createpsbt: Option<CreatepsbtResponse>,
25    pub createrawtransaction: Option<CreaterawtransactionResponse>,
26    pub createwallet: Option<CreatewalletResponse>,
27    pub createwalletdescriptor: Option<CreatewalletdescriptorResponse>,
28    pub decodepsbt: Option<DecodepsbtResponse>,
29    pub decoderawtransaction: Option<DecoderawtransactionResponse>,
30    pub decodescript: Option<DecodescriptResponse>,
31    pub deriveaddresses: Option<DeriveaddressesResponse>,
32    pub descriptorprocesspsbt: Option<DescriptorprocesspsbtResponse>,
33    pub disconnectnode: (),
34    pub dumptxoutset: Option<DumptxoutsetResponse>,
35    pub echo: Option<EchoResponse>,
36    pub echoipc: Option<EchoipcResponse>,
37    pub echojson: Option<EchojsonResponse>,
38    pub encryptwallet: Option<EncryptwalletResponse>,
39    pub enumeratesigners: Option<EnumeratesignersResponse>,
40    pub estimaterawfee: Option<EstimaterawfeeResponse>,
41    pub estimatesmartfee: Option<EstimatesmartfeeResponse>,
42    pub finalizepsbt: Option<FinalizepsbtResponse>,
43    pub fundrawtransaction: Option<FundrawtransactionResponse>,
44    pub generate: (),
45    pub generateblock: Option<GenerateblockResponse>,
46    pub generatetoaddress: Option<GeneratetoaddressResponse>,
47    pub generatetodescriptor: Option<GeneratetodescriptorResponse>,
48    pub getaddednodeinfo: Option<GetaddednodeinfoResponse>,
49    pub getaddressesbylabel: Option<GetaddressesbylabelResponse>,
50    pub getaddressinfo: Option<GetaddressinfoResponse>,
51    pub getaddrmaninfo: Option<GetaddrmaninfoResponse>,
52    pub getbalance: Option<GetbalanceResponse>,
53    pub getbalances: Option<GetbalancesResponse>,
54    pub getbestblockhash: Option<GetbestblockhashResponse>,
55    pub getblock: Option<GetblockResponse>,
56    pub getblockchaininfo: Option<GetblockchaininfoResponse>,
57    pub getblockcount: Option<GetblockcountResponse>,
58    pub getblockfilter: Option<GetblockfilterResponse>,
59    pub getblockfrompeer: Option<GetblockfrompeerResponse>,
60    pub getblockhash: Option<GetblockhashResponse>,
61    pub getblockheader: Option<GetblockheaderResponse>,
62    pub getblockstats: Option<GetblockstatsResponse>,
63    pub getblocktemplate: Option<GetblocktemplateResponse>,
64    pub getchainstates: Option<GetchainstatesResponse>,
65    pub getchaintips: Option<GetchaintipsResponse>,
66    pub getchaintxstats: Option<GetchaintxstatsResponse>,
67    pub getconnectioncount: Option<GetconnectioncountResponse>,
68    pub getdeploymentinfo: Option<GetdeploymentinfoResponse>,
69    pub getdescriptoractivity: Option<GetdescriptoractivityResponse>,
70    pub getdescriptorinfo: Option<GetdescriptorinfoResponse>,
71    pub getdifficulty: Option<GetdifficultyResponse>,
72    pub gethdkeys: Option<GethdkeysResponse>,
73    pub getindexinfo: Option<GetindexinfoResponse>,
74    pub getmemoryinfo: Option<GetmemoryinfoResponse>,
75    pub getmempoolancestors: Option<GetmempoolancestorsResponse>,
76    pub getmempooldescendants: Option<GetmempooldescendantsResponse>,
77    pub getmempoolentry: Option<GetmempoolentryResponse>,
78    pub getmempoolinfo: Option<GetmempoolinfoResponse>,
79    pub getmininginfo: Option<GetmininginfoResponse>,
80    pub getnettotals: Option<GetnettotalsResponse>,
81    pub getnetworkhashps: Option<GetnetworkhashpsResponse>,
82    pub getnetworkinfo: Option<GetnetworkinfoResponse>,
83    pub getnewaddress: Option<GetnewaddressResponse>,
84    pub getnodeaddresses: Option<GetnodeaddressesResponse>,
85    pub getorphantxs: Option<GetorphantxsResponse>,
86    pub getpeerinfo: Option<GetpeerinfoResponse>,
87    pub getprioritisedtransactions: Option<GetprioritisedtransactionsResponse>,
88    pub getrawaddrman: Option<GetrawaddrmanResponse>,
89    pub getrawchangeaddress: Option<GetrawchangeaddressResponse>,
90    pub getrawmempool: Option<GetrawmempoolResponse>,
91    pub getrawtransaction: Option<GetrawtransactionResponse>,
92    pub getreceivedbyaddress: Option<GetreceivedbyaddressResponse>,
93    pub getreceivedbylabel: Option<GetreceivedbylabelResponse>,
94    pub getrpcinfo: Option<GetrpcinfoResponse>,
95    pub gettransaction: Option<GettransactionResponse>,
96    pub gettxout: Option<GettxoutResponse>,
97    pub gettxoutproof: Option<GettxoutproofResponse>,
98    pub gettxoutsetinfo: Option<GettxoutsetinfoResponse>,
99    pub gettxspendingprevout: Option<GettxspendingprevoutResponse>,
100    pub getwalletinfo: Option<GetwalletinfoResponse>,
101    pub getzmqnotifications: Option<GetzmqnotificationsResponse>,
102    pub help: Option<HelpResponse>,
103    pub importdescriptors: Option<ImportdescriptorsResponse>,
104    pub importmempool: Option<ImportmempoolResponse>,
105    pub importprunedfunds: (),
106    pub invalidateblock: (),
107    pub joinpsbts: Option<JoinpsbtsResponse>,
108    pub keypoolrefill: (),
109    pub listaddressgroupings: Option<ListaddressgroupingsResponse>,
110    pub listbanned: Option<ListbannedResponse>,
111    pub listdescriptors: Option<ListdescriptorsResponse>,
112    pub listlabels: Option<ListlabelsResponse>,
113    pub listlockunspent: Option<ListlockunspentResponse>,
114    pub listreceivedbyaddress: Option<ListreceivedbyaddressResponse>,
115    pub listreceivedbylabel: Option<ListreceivedbylabelResponse>,
116    pub listsinceblock: Option<ListsinceblockResponse>,
117    pub listtransactions: Option<ListtransactionsResponse>,
118    pub listunspent: Option<ListunspentResponse>,
119    pub listwalletdir: Option<ListwalletdirResponse>,
120    pub listwallets: Option<ListwalletsResponse>,
121    pub loadtxoutset: Option<LoadtxoutsetResponse>,
122    pub loadwallet: Option<LoadwalletResponse>,
123    pub lockunspent: Option<LockunspentResponse>,
124    pub logging: Option<LoggingResponse>,
125    pub migratewallet: Option<MigratewalletResponse>,
126    pub mockscheduler: (),
127    pub ping: (),
128    pub preciousblock: (),
129    pub prioritisetransaction: Option<PrioritisetransactionResponse>,
130    pub pruneblockchain: Option<PruneblockchainResponse>,
131    pub psbtbumpfee: Option<PsbtbumpfeeResponse>,
132    pub reconsiderblock: (),
133    pub removeprunedfunds: (),
134    pub rescanblockchain: Option<RescanblockchainResponse>,
135    pub restorewallet: Option<RestorewalletResponse>,
136    pub savemempool: Option<SavemempoolResponse>,
137    pub scanblocks: Option<ScanblocksResponse>,
138    pub scantxoutset: Option<ScantxoutsetResponse>,
139    pub schema: Option<SchemaResponse>,
140    pub send: Option<SendResponse>,
141    pub sendall: Option<SendallResponse>,
142    pub sendmany: Option<SendmanyResponse>,
143    pub sendmsgtopeer: Option<SendmsgtopeerResponse>,
144    pub sendrawtransaction: Option<SendrawtransactionResponse>,
145    pub sendtoaddress: Option<SendtoaddressResponse>,
146    pub setban: (),
147    pub setlabel: (),
148    pub setmocktime: (),
149    pub setnetworkactive: Option<SetnetworkactiveResponse>,
150    pub settxfee: Option<SettxfeeResponse>,
151    pub setwalletflag: Option<SetwalletflagResponse>,
152    pub signmessage: Option<SignmessageResponse>,
153    pub signmessagewithprivkey: Option<SignmessagewithprivkeyResponse>,
154    pub signrawtransactionwithkey: Option<SignrawtransactionwithkeyResponse>,
155    pub signrawtransactionwithwallet: Option<SignrawtransactionwithwalletResponse>,
156    pub simulaterawtransaction: Option<SimulaterawtransactionResponse>,
157    pub stop: Option<StopResponse>,
158    pub submitblock: Option<SubmitblockResponse>,
159    pub submitheader: (),
160    pub submitpackage: Option<SubmitpackageResponse>,
161    pub syncwithvalidationinterfacequeue: (),
162    pub testmempoolaccept: Option<TestmempoolacceptResponse>,
163    pub unloadwallet: Option<UnloadwalletResponse>,
164    pub uptime: Option<UptimeResponse>,
165    pub utxoupdatepsbt: Option<UtxoupdatepsbtResponse>,
166    pub validateaddress: Option<ValidateaddressResponse>,
167    pub verifychain: Option<VerifychainResponse>,
168    pub verifymessage: Option<VerifymessageResponse>,
169    pub verifytxoutproof: Option<VerifytxoutproofResponse>,
170    pub waitforblock: Option<WaitforblockResponse>,
171    pub waitforblockheight: Option<WaitforblockheightResponse>,
172    pub waitfornewblock: Option<WaitfornewblockResponse>,
173    pub walletcreatefundedpsbt: Option<WalletcreatefundedpsbtResponse>,
174    pub walletdisplayaddress: Option<WalletdisplayaddressResponse>,
175    pub walletlock: (),
176    pub walletpassphrase: (),
177    pub walletpassphrasechange: (),
178    pub walletprocesspsbt: Option<WalletprocesspsbtResponse>,
179}
180
181/// Fluent builder for batching multiple RPC calls
182pub struct BatchBuilder {
183    tx: BatchTransport,
184    calls: Vec<(&'static str, Vec<Value>)>,
185}
186
187impl BatchBuilder {
188    /// Wraps a transport and begins a batch
189    pub fn new(inner: Arc<dyn TransportTrait>) -> Self {
190        let tx = BatchTransport::new(inner);
191        tx.begin_batch();
192        BatchBuilder { tx, calls: Vec::new() }
193    }
194
195    /// Queue a `abandontransaction` RPC call
196    pub fn abandontransaction(mut self, txid: Value) -> Self {
197        self.calls.push(("abandontransaction", vec![json!(txid)]));
198        self
199    }
200
201    /// Queue a `abortrescan` RPC call
202    pub fn abortrescan(mut self) -> Self {
203        self.calls.push(("abortrescan", Vec::new()));
204        self
205    }
206
207    /// Queue a `addconnection` RPC call
208    pub fn addconnection(
209        mut self,
210        address: Value,
211        connection_type: Value,
212        v2transport: Value,
213    ) -> Self {
214        self.calls.push((
215            "addconnection",
216            vec![json!(address), json!(connection_type), json!(v2transport)],
217        ));
218        self
219    }
220
221    /// Queue a `addnode` RPC call
222    pub fn addnode(mut self, node: Value, command: Value, v2transport: Value) -> Self {
223        self.calls.push(("addnode", vec![json!(node), json!(command), json!(v2transport)]));
224        self
225    }
226
227    /// Queue a `addpeeraddress` RPC call
228    pub fn addpeeraddress(mut self, address: Value, port: Value, tried: Value) -> Self {
229        self.calls.push(("addpeeraddress", vec![json!(address), json!(port), json!(tried)]));
230        self
231    }
232
233    /// Queue a `analyzepsbt` RPC call
234    pub fn analyzepsbt(mut self, psbt: Value) -> Self {
235        self.calls.push(("analyzepsbt", vec![json!(psbt)]));
236        self
237    }
238
239    /// Queue a `backupwallet` RPC call
240    pub fn backupwallet(mut self, destination: Value) -> Self {
241        self.calls.push(("backupwallet", vec![json!(destination)]));
242        self
243    }
244
245    /// Queue a `bumpfee` RPC call
246    pub fn bumpfee(mut self, txid: Value, options: Value) -> Self {
247        self.calls.push(("bumpfee", vec![json!(txid), json!(options)]));
248        self
249    }
250
251    /// Queue a `clearbanned` RPC call
252    pub fn clearbanned(mut self) -> Self {
253        self.calls.push(("clearbanned", Vec::new()));
254        self
255    }
256
257    /// Queue a `combinepsbt` RPC call
258    pub fn combinepsbt(mut self, txs: Value) -> Self {
259        self.calls.push(("combinepsbt", vec![json!(txs)]));
260        self
261    }
262
263    /// Queue a `combinerawtransaction` RPC call
264    pub fn combinerawtransaction(mut self, txs: Value) -> Self {
265        self.calls.push(("combinerawtransaction", vec![json!(txs)]));
266        self
267    }
268
269    /// Queue a `converttopsbt` RPC call
270    pub fn converttopsbt(
271        mut self,
272        hexstring: Value,
273        permitsigdata: Value,
274        iswitness: Value,
275    ) -> Self {
276        self.calls.push((
277            "converttopsbt",
278            vec![json!(hexstring), json!(permitsigdata), json!(iswitness)],
279        ));
280        self
281    }
282
283    /// Queue a `createmultisig` RPC call
284    pub fn createmultisig(mut self, nrequired: Value, keys: Value, address_type: Value) -> Self {
285        self.calls
286            .push(("createmultisig", vec![json!(nrequired), json!(keys), json!(address_type)]));
287        self
288    }
289
290    /// Queue a `createpsbt` RPC call
291    pub fn createpsbt(
292        mut self,
293        inputs: Value,
294        outputs: Value,
295        locktime: Value,
296        replaceable: Value,
297        version: Value,
298    ) -> Self {
299        self.calls.push((
300            "createpsbt",
301            vec![
302                json!(inputs),
303                json!(outputs),
304                json!(locktime),
305                json!(replaceable),
306                json!(version),
307            ],
308        ));
309        self
310    }
311
312    /// Queue a `createrawtransaction` RPC call
313    pub fn createrawtransaction(
314        mut self,
315        inputs: Value,
316        outputs: Value,
317        locktime: Value,
318        replaceable: Value,
319        version: Value,
320    ) -> Self {
321        self.calls.push((
322            "createrawtransaction",
323            vec![
324                json!(inputs),
325                json!(outputs),
326                json!(locktime),
327                json!(replaceable),
328                json!(version),
329            ],
330        ));
331        self
332    }
333
334    #[allow(clippy::too_many_arguments)]
335    /// Queue a `createwallet` RPC call
336    pub fn createwallet(
337        mut self,
338        wallet_name: Value,
339        disable_private_keys: Value,
340        blank: Value,
341        passphrase: Value,
342        avoid_reuse: Value,
343        descriptors: Value,
344        load_on_startup: Value,
345        external_signer: Value,
346    ) -> Self {
347        self.calls.push((
348            "createwallet",
349            vec![
350                json!(wallet_name),
351                json!(disable_private_keys),
352                json!(blank),
353                json!(passphrase),
354                json!(avoid_reuse),
355                json!(descriptors),
356                json!(load_on_startup),
357                json!(external_signer),
358            ],
359        ));
360        self
361    }
362
363    /// Queue a `createwalletdescriptor` RPC call
364    pub fn createwalletdescriptor(mut self, r#type: Value, options: Value) -> Self {
365        self.calls.push(("createwalletdescriptor", vec![json!(r#type), json!(options)]));
366        self
367    }
368
369    /// Queue a `decodepsbt` RPC call
370    pub fn decodepsbt(mut self, psbt: Value) -> Self {
371        self.calls.push(("decodepsbt", vec![json!(psbt)]));
372        self
373    }
374
375    /// Queue a `decoderawtransaction` RPC call
376    pub fn decoderawtransaction(mut self, hexstring: Value, iswitness: Value) -> Self {
377        self.calls.push(("decoderawtransaction", vec![json!(hexstring), json!(iswitness)]));
378        self
379    }
380
381    /// Queue a `decodescript` RPC call
382    pub fn decodescript(mut self, hexstring: Value) -> Self {
383        self.calls.push(("decodescript", vec![json!(hexstring)]));
384        self
385    }
386
387    /// Queue a `deriveaddresses` RPC call
388    pub fn deriveaddresses(mut self, descriptor: Value, range: Value) -> Self {
389        self.calls.push(("deriveaddresses", vec![json!(descriptor), json!(range)]));
390        self
391    }
392
393    /// Queue a `descriptorprocesspsbt` RPC call
394    pub fn descriptorprocesspsbt(
395        mut self,
396        psbt: Value,
397        descriptors: Value,
398        sighashtype: Value,
399        bip32derivs: Value,
400        finalize: Value,
401    ) -> Self {
402        self.calls.push((
403            "descriptorprocesspsbt",
404            vec![
405                json!(psbt),
406                json!(descriptors),
407                json!(sighashtype),
408                json!(bip32derivs),
409                json!(finalize),
410            ],
411        ));
412        self
413    }
414
415    /// Queue a `disconnectnode` RPC call
416    pub fn disconnectnode(mut self, address: Value, nodeid: Value) -> Self {
417        self.calls.push(("disconnectnode", vec![json!(address), json!(nodeid)]));
418        self
419    }
420
421    /// Queue a `dumptxoutset` RPC call
422    pub fn dumptxoutset(mut self, path: Value, r#type: Value, options: Value) -> Self {
423        self.calls.push(("dumptxoutset", vec![json!(path), json!(r#type), json!(options)]));
424        self
425    }
426
427    #[allow(clippy::too_many_arguments)]
428    /// Queue a `echo` RPC call
429    pub fn echo(
430        mut self,
431        arg0: Value,
432        arg1: Value,
433        arg2: Value,
434        arg3: Value,
435        arg4: Value,
436        arg5: Value,
437        arg6: Value,
438        arg7: Value,
439        arg8: Value,
440        arg9: Value,
441    ) -> Self {
442        self.calls.push((
443            "echo",
444            vec![
445                json!(arg0),
446                json!(arg1),
447                json!(arg2),
448                json!(arg3),
449                json!(arg4),
450                json!(arg5),
451                json!(arg6),
452                json!(arg7),
453                json!(arg8),
454                json!(arg9),
455            ],
456        ));
457        self
458    }
459
460    /// Queue a `echoipc` RPC call
461    pub fn echoipc(mut self, arg: Value) -> Self {
462        self.calls.push(("echoipc", vec![json!(arg)]));
463        self
464    }
465
466    #[allow(clippy::too_many_arguments)]
467    /// Queue a `echojson` RPC call
468    pub fn echojson(
469        mut self,
470        arg0: Value,
471        arg1: Value,
472        arg2: Value,
473        arg3: Value,
474        arg4: Value,
475        arg5: Value,
476        arg6: Value,
477        arg7: Value,
478        arg8: Value,
479        arg9: Value,
480    ) -> Self {
481        self.calls.push((
482            "echojson",
483            vec![
484                json!(arg0),
485                json!(arg1),
486                json!(arg2),
487                json!(arg3),
488                json!(arg4),
489                json!(arg5),
490                json!(arg6),
491                json!(arg7),
492                json!(arg8),
493                json!(arg9),
494            ],
495        ));
496        self
497    }
498
499    /// Queue a `encryptwallet` RPC call
500    pub fn encryptwallet(mut self, passphrase: Value) -> Self {
501        self.calls.push(("encryptwallet", vec![json!(passphrase)]));
502        self
503    }
504
505    /// Queue a `enumeratesigners` RPC call
506    pub fn enumeratesigners(mut self) -> Self {
507        self.calls.push(("enumeratesigners", Vec::new()));
508        self
509    }
510
511    /// Queue a `estimaterawfee` RPC call
512    pub fn estimaterawfee(mut self, conf_target: Value, threshold: Value) -> Self {
513        self.calls.push(("estimaterawfee", vec![json!(conf_target), json!(threshold)]));
514        self
515    }
516
517    /// Queue a `estimatesmartfee` RPC call
518    pub fn estimatesmartfee(mut self, conf_target: Value, estimate_mode: Value) -> Self {
519        self.calls.push(("estimatesmartfee", vec![json!(conf_target), json!(estimate_mode)]));
520        self
521    }
522
523    /// Queue a `finalizepsbt` RPC call
524    pub fn finalizepsbt(mut self, psbt: Value, extract: Value) -> Self {
525        self.calls.push(("finalizepsbt", vec![json!(psbt), json!(extract)]));
526        self
527    }
528
529    /// Queue a `fundrawtransaction` RPC call
530    pub fn fundrawtransaction(
531        mut self,
532        hexstring: Value,
533        options: Value,
534        iswitness: Value,
535    ) -> Self {
536        self.calls
537            .push(("fundrawtransaction", vec![json!(hexstring), json!(options), json!(iswitness)]));
538        self
539    }
540
541    /// Queue a `generate` RPC call
542    pub fn generate(mut self) -> Self {
543        self.calls.push(("generate", Vec::new()));
544        self
545    }
546
547    /// Queue a `generateblock` RPC call
548    pub fn generateblock(mut self, output: Value, transactions: Value, submit: Value) -> Self {
549        self.calls.push(("generateblock", vec![json!(output), json!(transactions), json!(submit)]));
550        self
551    }
552
553    /// Queue a `generatetoaddress` RPC call
554    pub fn generatetoaddress(mut self, nblocks: Value, address: Value, maxtries: Value) -> Self {
555        self.calls
556            .push(("generatetoaddress", vec![json!(nblocks), json!(address), json!(maxtries)]));
557        self
558    }
559
560    /// Queue a `generatetodescriptor` RPC call
561    pub fn generatetodescriptor(
562        mut self,
563        num_blocks: Value,
564        descriptor: Value,
565        maxtries: Value,
566    ) -> Self {
567        self.calls.push((
568            "generatetodescriptor",
569            vec![json!(num_blocks), json!(descriptor), json!(maxtries)],
570        ));
571        self
572    }
573
574    /// Queue a `getaddednodeinfo` RPC call
575    pub fn getaddednodeinfo(mut self, node: Value) -> Self {
576        self.calls.push(("getaddednodeinfo", vec![json!(node)]));
577        self
578    }
579
580    /// Queue a `getaddressesbylabel` RPC call
581    pub fn getaddressesbylabel(mut self, label: Value) -> Self {
582        self.calls.push(("getaddressesbylabel", vec![json!(label)]));
583        self
584    }
585
586    /// Queue a `getaddressinfo` RPC call
587    pub fn getaddressinfo(mut self, address: Value) -> Self {
588        self.calls.push(("getaddressinfo", vec![json!(address)]));
589        self
590    }
591
592    /// Queue a `getaddrmaninfo` RPC call
593    pub fn getaddrmaninfo(mut self) -> Self {
594        self.calls.push(("getaddrmaninfo", Vec::new()));
595        self
596    }
597
598    /// Queue a `getbalance` RPC call
599    pub fn getbalance(
600        mut self,
601        dummy: Value,
602        minconf: Value,
603        include_watchonly: Value,
604        avoid_reuse: Value,
605    ) -> Self {
606        self.calls.push((
607            "getbalance",
608            vec![json!(dummy), json!(minconf), json!(include_watchonly), json!(avoid_reuse)],
609        ));
610        self
611    }
612
613    /// Queue a `getbalances` RPC call
614    pub fn getbalances(mut self) -> Self {
615        self.calls.push(("getbalances", Vec::new()));
616        self
617    }
618
619    /// Queue a `getbestblockhash` RPC call
620    pub fn getbestblockhash(mut self) -> Self {
621        self.calls.push(("getbestblockhash", Vec::new()));
622        self
623    }
624
625    /// Queue a `getblock` RPC call
626    pub fn getblock(mut self, blockhash: Value, verbosity: Value) -> Self {
627        self.calls.push(("getblock", vec![json!(blockhash), json!(verbosity)]));
628        self
629    }
630
631    /// Queue a `getblockchaininfo` RPC call
632    pub fn getblockchaininfo(mut self) -> Self {
633        self.calls.push(("getblockchaininfo", Vec::new()));
634        self
635    }
636
637    /// Queue a `getblockcount` RPC call
638    pub fn getblockcount(mut self) -> Self {
639        self.calls.push(("getblockcount", Vec::new()));
640        self
641    }
642
643    /// Queue a `getblockfilter` RPC call
644    pub fn getblockfilter(mut self, blockhash: Value, filtertype: Value) -> Self {
645        self.calls.push(("getblockfilter", vec![json!(blockhash), json!(filtertype)]));
646        self
647    }
648
649    /// Queue a `getblockfrompeer` RPC call
650    pub fn getblockfrompeer(mut self, blockhash: Value, peer_id: Value) -> Self {
651        self.calls.push(("getblockfrompeer", vec![json!(blockhash), json!(peer_id)]));
652        self
653    }
654
655    /// Queue a `getblockhash` RPC call
656    pub fn getblockhash(mut self, height: Value) -> Self {
657        self.calls.push(("getblockhash", vec![json!(height)]));
658        self
659    }
660
661    /// Queue a `getblockheader` RPC call
662    pub fn getblockheader(mut self, blockhash: Value, verbose: Value) -> Self {
663        self.calls.push(("getblockheader", vec![json!(blockhash), json!(verbose)]));
664        self
665    }
666
667    /// Queue a `getblockstats` RPC call
668    pub fn getblockstats(mut self, hash_or_height: Value, stats: Value) -> Self {
669        self.calls.push(("getblockstats", vec![json!(hash_or_height), json!(stats)]));
670        self
671    }
672
673    /// Queue a `getblocktemplate` RPC call
674    pub fn getblocktemplate(mut self, template_request: Value) -> Self {
675        self.calls.push(("getblocktemplate", vec![json!(template_request)]));
676        self
677    }
678
679    /// Queue a `getchainstates` RPC call
680    pub fn getchainstates(mut self) -> Self {
681        self.calls.push(("getchainstates", Vec::new()));
682        self
683    }
684
685    /// Queue a `getchaintips` RPC call
686    pub fn getchaintips(mut self) -> Self {
687        self.calls.push(("getchaintips", Vec::new()));
688        self
689    }
690
691    /// Queue a `getchaintxstats` RPC call
692    pub fn getchaintxstats(mut self, nblocks: Value, blockhash: Value) -> Self {
693        self.calls.push(("getchaintxstats", vec![json!(nblocks), json!(blockhash)]));
694        self
695    }
696
697    /// Queue a `getconnectioncount` RPC call
698    pub fn getconnectioncount(mut self) -> Self {
699        self.calls.push(("getconnectioncount", Vec::new()));
700        self
701    }
702
703    /// Queue a `getdeploymentinfo` RPC call
704    pub fn getdeploymentinfo(mut self, blockhash: Value) -> Self {
705        self.calls.push(("getdeploymentinfo", vec![json!(blockhash)]));
706        self
707    }
708
709    /// Queue a `getdescriptoractivity` RPC call
710    pub fn getdescriptoractivity(
711        mut self,
712        blockhashes: Value,
713        scanobjects: Value,
714        include_mempool: Value,
715    ) -> Self {
716        self.calls.push((
717            "getdescriptoractivity",
718            vec![json!(blockhashes), json!(scanobjects), json!(include_mempool)],
719        ));
720        self
721    }
722
723    /// Queue a `getdescriptorinfo` RPC call
724    pub fn getdescriptorinfo(mut self, descriptor: Value) -> Self {
725        self.calls.push(("getdescriptorinfo", vec![json!(descriptor)]));
726        self
727    }
728
729    /// Queue a `getdifficulty` RPC call
730    pub fn getdifficulty(mut self) -> Self {
731        self.calls.push(("getdifficulty", Vec::new()));
732        self
733    }
734
735    /// Queue a `gethdkeys` RPC call
736    pub fn gethdkeys(mut self, options: Value) -> Self {
737        self.calls.push(("gethdkeys", vec![json!(options)]));
738        self
739    }
740
741    /// Queue a `getindexinfo` RPC call
742    pub fn getindexinfo(mut self, index_name: Value) -> Self {
743        self.calls.push(("getindexinfo", vec![json!(index_name)]));
744        self
745    }
746
747    /// Queue a `getmemoryinfo` RPC call
748    pub fn getmemoryinfo(mut self, mode: Value) -> Self {
749        self.calls.push(("getmemoryinfo", vec![json!(mode)]));
750        self
751    }
752
753    /// Queue a `getmempoolancestors` RPC call
754    pub fn getmempoolancestors(mut self, txid: Value, verbose: Value) -> Self {
755        self.calls.push(("getmempoolancestors", vec![json!(txid), json!(verbose)]));
756        self
757    }
758
759    /// Queue a `getmempooldescendants` RPC call
760    pub fn getmempooldescendants(mut self, txid: Value, verbose: Value) -> Self {
761        self.calls.push(("getmempooldescendants", vec![json!(txid), json!(verbose)]));
762        self
763    }
764
765    /// Queue a `getmempoolentry` RPC call
766    pub fn getmempoolentry(mut self, txid: Value) -> Self {
767        self.calls.push(("getmempoolentry", vec![json!(txid)]));
768        self
769    }
770
771    /// Queue a `getmempoolinfo` RPC call
772    pub fn getmempoolinfo(mut self) -> Self {
773        self.calls.push(("getmempoolinfo", Vec::new()));
774        self
775    }
776
777    /// Queue a `getmininginfo` RPC call
778    pub fn getmininginfo(mut self) -> Self {
779        self.calls.push(("getmininginfo", Vec::new()));
780        self
781    }
782
783    /// Queue a `getnettotals` RPC call
784    pub fn getnettotals(mut self) -> Self {
785        self.calls.push(("getnettotals", Vec::new()));
786        self
787    }
788
789    /// Queue a `getnetworkhashps` RPC call
790    pub fn getnetworkhashps(mut self, nblocks: Value, height: Value) -> Self {
791        self.calls.push(("getnetworkhashps", vec![json!(nblocks), json!(height)]));
792        self
793    }
794
795    /// Queue a `getnetworkinfo` RPC call
796    pub fn getnetworkinfo(mut self) -> Self {
797        self.calls.push(("getnetworkinfo", Vec::new()));
798        self
799    }
800
801    /// Queue a `getnewaddress` RPC call
802    pub fn getnewaddress(mut self, label: Value, address_type: Value) -> Self {
803        self.calls.push(("getnewaddress", vec![json!(label), json!(address_type)]));
804        self
805    }
806
807    /// Queue a `getnodeaddresses` RPC call
808    pub fn getnodeaddresses(mut self, count: Value, network: Value) -> Self {
809        self.calls.push(("getnodeaddresses", vec![json!(count), json!(network)]));
810        self
811    }
812
813    /// Queue a `getorphantxs` RPC call
814    pub fn getorphantxs(mut self, verbosity: Value) -> Self {
815        self.calls.push(("getorphantxs", vec![json!(verbosity)]));
816        self
817    }
818
819    /// Queue a `getpeerinfo` RPC call
820    pub fn getpeerinfo(mut self) -> Self {
821        self.calls.push(("getpeerinfo", Vec::new()));
822        self
823    }
824
825    /// Queue a `getprioritisedtransactions` RPC call
826    pub fn getprioritisedtransactions(mut self) -> Self {
827        self.calls.push(("getprioritisedtransactions", Vec::new()));
828        self
829    }
830
831    /// Queue a `getrawaddrman` RPC call
832    pub fn getrawaddrman(mut self) -> Self {
833        self.calls.push(("getrawaddrman", Vec::new()));
834        self
835    }
836
837    /// Queue a `getrawchangeaddress` RPC call
838    pub fn getrawchangeaddress(mut self, address_type: Value) -> Self {
839        self.calls.push(("getrawchangeaddress", vec![json!(address_type)]));
840        self
841    }
842
843    /// Queue a `getrawmempool` RPC call
844    pub fn getrawmempool(mut self, verbose: Value, mempool_sequence: Value) -> Self {
845        self.calls.push(("getrawmempool", vec![json!(verbose), json!(mempool_sequence)]));
846        self
847    }
848
849    /// Queue a `getrawtransaction` RPC call
850    pub fn getrawtransaction(mut self, txid: Value, verbosity: Value, blockhash: Value) -> Self {
851        self.calls
852            .push(("getrawtransaction", vec![json!(txid), json!(verbosity), json!(blockhash)]));
853        self
854    }
855
856    /// Queue a `getreceivedbyaddress` RPC call
857    pub fn getreceivedbyaddress(
858        mut self,
859        address: Value,
860        minconf: Value,
861        include_immature_coinbase: Value,
862    ) -> Self {
863        self.calls.push((
864            "getreceivedbyaddress",
865            vec![json!(address), json!(minconf), json!(include_immature_coinbase)],
866        ));
867        self
868    }
869
870    /// Queue a `getreceivedbylabel` RPC call
871    pub fn getreceivedbylabel(
872        mut self,
873        label: Value,
874        minconf: Value,
875        include_immature_coinbase: Value,
876    ) -> Self {
877        self.calls.push((
878            "getreceivedbylabel",
879            vec![json!(label), json!(minconf), json!(include_immature_coinbase)],
880        ));
881        self
882    }
883
884    /// Queue a `getrpcinfo` RPC call
885    pub fn getrpcinfo(mut self) -> Self {
886        self.calls.push(("getrpcinfo", Vec::new()));
887        self
888    }
889
890    /// Queue a `gettransaction` RPC call
891    pub fn gettransaction(mut self, txid: Value, include_watchonly: Value, verbose: Value) -> Self {
892        self.calls
893            .push(("gettransaction", vec![json!(txid), json!(include_watchonly), json!(verbose)]));
894        self
895    }
896
897    /// Queue a `gettxout` RPC call
898    pub fn gettxout(mut self, txid: Value, n: Value, include_mempool: Value) -> Self {
899        self.calls.push(("gettxout", vec![json!(txid), json!(n), json!(include_mempool)]));
900        self
901    }
902
903    /// Queue a `gettxoutproof` RPC call
904    pub fn gettxoutproof(mut self, txids: Value, blockhash: Value) -> Self {
905        self.calls.push(("gettxoutproof", vec![json!(txids), json!(blockhash)]));
906        self
907    }
908
909    /// Queue a `gettxoutsetinfo` RPC call
910    pub fn gettxoutsetinfo(
911        mut self,
912        hash_type: Value,
913        hash_or_height: Value,
914        use_index: Value,
915    ) -> Self {
916        self.calls.push((
917            "gettxoutsetinfo",
918            vec![json!(hash_type), json!(hash_or_height), json!(use_index)],
919        ));
920        self
921    }
922
923    /// Queue a `gettxspendingprevout` RPC call
924    pub fn gettxspendingprevout(mut self, outputs: Value) -> Self {
925        self.calls.push(("gettxspendingprevout", vec![json!(outputs)]));
926        self
927    }
928
929    /// Queue a `getwalletinfo` RPC call
930    pub fn getwalletinfo(mut self) -> Self {
931        self.calls.push(("getwalletinfo", Vec::new()));
932        self
933    }
934
935    /// Queue a `getzmqnotifications` RPC call
936    pub fn getzmqnotifications(mut self) -> Self {
937        self.calls.push(("getzmqnotifications", Vec::new()));
938        self
939    }
940
941    /// Queue a `help` RPC call
942    pub fn help(mut self, command: Value) -> Self {
943        self.calls.push(("help", vec![json!(command)]));
944        self
945    }
946
947    /// Queue a `importdescriptors` RPC call
948    pub fn importdescriptors(mut self, requests: Value) -> Self {
949        self.calls.push(("importdescriptors", vec![json!(requests)]));
950        self
951    }
952
953    /// Queue a `importmempool` RPC call
954    pub fn importmempool(mut self, filepath: Value, options: Value) -> Self {
955        self.calls.push(("importmempool", vec![json!(filepath), json!(options)]));
956        self
957    }
958
959    /// Queue a `importprunedfunds` RPC call
960    pub fn importprunedfunds(mut self, rawtransaction: Value, txoutproof: Value) -> Self {
961        self.calls.push(("importprunedfunds", vec![json!(rawtransaction), json!(txoutproof)]));
962        self
963    }
964
965    /// Queue a `invalidateblock` RPC call
966    pub fn invalidateblock(mut self, blockhash: Value) -> Self {
967        self.calls.push(("invalidateblock", vec![json!(blockhash)]));
968        self
969    }
970
971    /// Queue a `joinpsbts` RPC call
972    pub fn joinpsbts(mut self, txs: Value) -> Self {
973        self.calls.push(("joinpsbts", vec![json!(txs)]));
974        self
975    }
976
977    /// Queue a `keypoolrefill` RPC call
978    pub fn keypoolrefill(mut self, newsize: Value) -> Self {
979        self.calls.push(("keypoolrefill", vec![json!(newsize)]));
980        self
981    }
982
983    /// Queue a `listaddressgroupings` RPC call
984    pub fn listaddressgroupings(mut self) -> Self {
985        self.calls.push(("listaddressgroupings", Vec::new()));
986        self
987    }
988
989    /// Queue a `listbanned` RPC call
990    pub fn listbanned(mut self) -> Self {
991        self.calls.push(("listbanned", Vec::new()));
992        self
993    }
994
995    /// Queue a `listdescriptors` RPC call
996    pub fn listdescriptors(mut self, private: Value) -> Self {
997        self.calls.push(("listdescriptors", vec![json!(private)]));
998        self
999    }
1000
1001    /// Queue a `listlabels` RPC call
1002    pub fn listlabels(mut self, purpose: Value) -> Self {
1003        self.calls.push(("listlabels", vec![json!(purpose)]));
1004        self
1005    }
1006
1007    /// Queue a `listlockunspent` RPC call
1008    pub fn listlockunspent(mut self) -> Self {
1009        self.calls.push(("listlockunspent", Vec::new()));
1010        self
1011    }
1012
1013    /// Queue a `listreceivedbyaddress` RPC call
1014    pub fn listreceivedbyaddress(
1015        mut self,
1016        minconf: Value,
1017        include_empty: Value,
1018        include_watchonly: Value,
1019        address_filter: Value,
1020        include_immature_coinbase: Value,
1021    ) -> Self {
1022        self.calls.push((
1023            "listreceivedbyaddress",
1024            vec![
1025                json!(minconf),
1026                json!(include_empty),
1027                json!(include_watchonly),
1028                json!(address_filter),
1029                json!(include_immature_coinbase),
1030            ],
1031        ));
1032        self
1033    }
1034
1035    /// Queue a `listreceivedbylabel` RPC call
1036    pub fn listreceivedbylabel(
1037        mut self,
1038        minconf: Value,
1039        include_empty: Value,
1040        include_watchonly: Value,
1041        include_immature_coinbase: Value,
1042    ) -> Self {
1043        self.calls.push((
1044            "listreceivedbylabel",
1045            vec![
1046                json!(minconf),
1047                json!(include_empty),
1048                json!(include_watchonly),
1049                json!(include_immature_coinbase),
1050            ],
1051        ));
1052        self
1053    }
1054
1055    /// Queue a `listsinceblock` RPC call
1056    pub fn listsinceblock(
1057        mut self,
1058        blockhash: Value,
1059        target_confirmations: Value,
1060        include_watchonly: Value,
1061        include_removed: Value,
1062        include_change: Value,
1063        label: Value,
1064    ) -> Self {
1065        self.calls.push((
1066            "listsinceblock",
1067            vec![
1068                json!(blockhash),
1069                json!(target_confirmations),
1070                json!(include_watchonly),
1071                json!(include_removed),
1072                json!(include_change),
1073                json!(label),
1074            ],
1075        ));
1076        self
1077    }
1078
1079    /// Queue a `listtransactions` RPC call
1080    pub fn listtransactions(
1081        mut self,
1082        label: Value,
1083        count: Value,
1084        skip: Value,
1085        include_watchonly: Value,
1086    ) -> Self {
1087        self.calls.push((
1088            "listtransactions",
1089            vec![json!(label), json!(count), json!(skip), json!(include_watchonly)],
1090        ));
1091        self
1092    }
1093
1094    /// Queue a `listunspent` RPC call
1095    pub fn listunspent(
1096        mut self,
1097        minconf: Value,
1098        maxconf: Value,
1099        addresses: Value,
1100        include_unsafe: Value,
1101        query_options: Value,
1102    ) -> Self {
1103        self.calls.push((
1104            "listunspent",
1105            vec![
1106                json!(minconf),
1107                json!(maxconf),
1108                json!(addresses),
1109                json!(include_unsafe),
1110                json!(query_options),
1111            ],
1112        ));
1113        self
1114    }
1115
1116    /// Queue a `listwalletdir` RPC call
1117    pub fn listwalletdir(mut self) -> Self {
1118        self.calls.push(("listwalletdir", Vec::new()));
1119        self
1120    }
1121
1122    /// Queue a `listwallets` RPC call
1123    pub fn listwallets(mut self) -> Self {
1124        self.calls.push(("listwallets", Vec::new()));
1125        self
1126    }
1127
1128    /// Queue a `loadtxoutset` RPC call
1129    pub fn loadtxoutset(mut self, path: Value) -> Self {
1130        self.calls.push(("loadtxoutset", vec![json!(path)]));
1131        self
1132    }
1133
1134    /// Queue a `loadwallet` RPC call
1135    pub fn loadwallet(mut self, filename: Value, load_on_startup: Value) -> Self {
1136        self.calls.push(("loadwallet", vec![json!(filename), json!(load_on_startup)]));
1137        self
1138    }
1139
1140    /// Queue a `lockunspent` RPC call
1141    pub fn lockunspent(mut self, unlock: Value, transactions: Value, persistent: Value) -> Self {
1142        self.calls
1143            .push(("lockunspent", vec![json!(unlock), json!(transactions), json!(persistent)]));
1144        self
1145    }
1146
1147    /// Queue a `logging` RPC call
1148    pub fn logging(mut self, include: Value, exclude: Value) -> Self {
1149        self.calls.push(("logging", vec![json!(include), json!(exclude)]));
1150        self
1151    }
1152
1153    /// Queue a `migratewallet` RPC call
1154    pub fn migratewallet(mut self, wallet_name: Value, passphrase: Value) -> Self {
1155        self.calls.push(("migratewallet", vec![json!(wallet_name), json!(passphrase)]));
1156        self
1157    }
1158
1159    /// Queue a `mockscheduler` RPC call
1160    pub fn mockscheduler(mut self, delta_time: Value) -> Self {
1161        self.calls.push(("mockscheduler", vec![json!(delta_time)]));
1162        self
1163    }
1164
1165    /// Queue a `ping` RPC call
1166    pub fn ping(mut self) -> Self {
1167        self.calls.push(("ping", Vec::new()));
1168        self
1169    }
1170
1171    /// Queue a `preciousblock` RPC call
1172    pub fn preciousblock(mut self, blockhash: Value) -> Self {
1173        self.calls.push(("preciousblock", vec![json!(blockhash)]));
1174        self
1175    }
1176
1177    /// Queue a `prioritisetransaction` RPC call
1178    pub fn prioritisetransaction(mut self, txid: Value, dummy: Value, fee_delta: Value) -> Self {
1179        self.calls
1180            .push(("prioritisetransaction", vec![json!(txid), json!(dummy), json!(fee_delta)]));
1181        self
1182    }
1183
1184    /// Queue a `pruneblockchain` RPC call
1185    pub fn pruneblockchain(mut self, height: Value) -> Self {
1186        self.calls.push(("pruneblockchain", vec![json!(height)]));
1187        self
1188    }
1189
1190    /// Queue a `psbtbumpfee` RPC call
1191    pub fn psbtbumpfee(mut self, txid: Value, options: Value) -> Self {
1192        self.calls.push(("psbtbumpfee", vec![json!(txid), json!(options)]));
1193        self
1194    }
1195
1196    /// Queue a `reconsiderblock` RPC call
1197    pub fn reconsiderblock(mut self, blockhash: Value) -> Self {
1198        self.calls.push(("reconsiderblock", vec![json!(blockhash)]));
1199        self
1200    }
1201
1202    /// Queue a `removeprunedfunds` RPC call
1203    pub fn removeprunedfunds(mut self, txid: Value) -> Self {
1204        self.calls.push(("removeprunedfunds", vec![json!(txid)]));
1205        self
1206    }
1207
1208    /// Queue a `rescanblockchain` RPC call
1209    pub fn rescanblockchain(mut self, start_height: Value, stop_height: Value) -> Self {
1210        self.calls.push(("rescanblockchain", vec![json!(start_height), json!(stop_height)]));
1211        self
1212    }
1213
1214    /// Queue a `restorewallet` RPC call
1215    pub fn restorewallet(
1216        mut self,
1217        wallet_name: Value,
1218        backup_file: Value,
1219        load_on_startup: Value,
1220    ) -> Self {
1221        self.calls.push((
1222            "restorewallet",
1223            vec![json!(wallet_name), json!(backup_file), json!(load_on_startup)],
1224        ));
1225        self
1226    }
1227
1228    /// Queue a `savemempool` RPC call
1229    pub fn savemempool(mut self) -> Self {
1230        self.calls.push(("savemempool", Vec::new()));
1231        self
1232    }
1233
1234    /// Queue a `scanblocks` RPC call
1235    pub fn scanblocks(
1236        mut self,
1237        action: Value,
1238        scanobjects: Value,
1239        start_height: Value,
1240        stop_height: Value,
1241        filtertype: Value,
1242        options: Value,
1243    ) -> Self {
1244        self.calls.push((
1245            "scanblocks",
1246            vec![
1247                json!(action),
1248                json!(scanobjects),
1249                json!(start_height),
1250                json!(stop_height),
1251                json!(filtertype),
1252                json!(options),
1253            ],
1254        ));
1255        self
1256    }
1257
1258    /// Queue a `scantxoutset` RPC call
1259    pub fn scantxoutset(mut self, action: Value, scanobjects: Value) -> Self {
1260        self.calls.push(("scantxoutset", vec![json!(action), json!(scanobjects)]));
1261        self
1262    }
1263
1264    /// Queue a `schema` RPC call
1265    pub fn schema(mut self) -> Self {
1266        self.calls.push(("schema", Vec::new()));
1267        self
1268    }
1269
1270    /// Queue a `send` RPC call
1271    pub fn send(
1272        mut self,
1273        outputs: Value,
1274        conf_target: Value,
1275        estimate_mode: Value,
1276        fee_rate: Value,
1277        options: Value,
1278        version: Value,
1279    ) -> Self {
1280        self.calls.push((
1281            "send",
1282            vec![
1283                json!(outputs),
1284                json!(conf_target),
1285                json!(estimate_mode),
1286                json!(fee_rate),
1287                json!(options),
1288                json!(version),
1289            ],
1290        ));
1291        self
1292    }
1293
1294    /// Queue a `sendall` RPC call
1295    pub fn sendall(
1296        mut self,
1297        recipients: Value,
1298        conf_target: Value,
1299        estimate_mode: Value,
1300        fee_rate: Value,
1301        options: Value,
1302    ) -> Self {
1303        self.calls.push((
1304            "sendall",
1305            vec![
1306                json!(recipients),
1307                json!(conf_target),
1308                json!(estimate_mode),
1309                json!(fee_rate),
1310                json!(options),
1311            ],
1312        ));
1313        self
1314    }
1315
1316    #[allow(clippy::too_many_arguments)]
1317    /// Queue a `sendmany` RPC call
1318    pub fn sendmany(
1319        mut self,
1320        dummy: Value,
1321        amounts: Value,
1322        minconf: Value,
1323        comment: Value,
1324        subtractfeefrom: Value,
1325        replaceable: Value,
1326        conf_target: Value,
1327        estimate_mode: Value,
1328        fee_rate: Value,
1329        verbose: Value,
1330    ) -> Self {
1331        self.calls.push((
1332            "sendmany",
1333            vec![
1334                json!(dummy),
1335                json!(amounts),
1336                json!(minconf),
1337                json!(comment),
1338                json!(subtractfeefrom),
1339                json!(replaceable),
1340                json!(conf_target),
1341                json!(estimate_mode),
1342                json!(fee_rate),
1343                json!(verbose),
1344            ],
1345        ));
1346        self
1347    }
1348
1349    /// Queue a `sendmsgtopeer` RPC call
1350    pub fn sendmsgtopeer(mut self, peer_id: Value, msg_type: Value, msg: Value) -> Self {
1351        self.calls.push(("sendmsgtopeer", vec![json!(peer_id), json!(msg_type), json!(msg)]));
1352        self
1353    }
1354
1355    /// Queue a `sendrawtransaction` RPC call
1356    pub fn sendrawtransaction(
1357        mut self,
1358        hexstring: Value,
1359        maxfeerate: Value,
1360        maxburnamount: Value,
1361    ) -> Self {
1362        self.calls.push((
1363            "sendrawtransaction",
1364            vec![json!(hexstring), json!(maxfeerate), json!(maxburnamount)],
1365        ));
1366        self
1367    }
1368
1369    #[allow(clippy::too_many_arguments)]
1370    /// Queue a `sendtoaddress` RPC call
1371    pub fn sendtoaddress(
1372        mut self,
1373        address: Value,
1374        amount: Value,
1375        comment: Value,
1376        comment_to: Value,
1377        subtractfeefromamount: Value,
1378        replaceable: Value,
1379        conf_target: Value,
1380        estimate_mode: Value,
1381        avoid_reuse: Value,
1382        fee_rate: Value,
1383        verbose: Value,
1384    ) -> Self {
1385        self.calls.push((
1386            "sendtoaddress",
1387            vec![
1388                json!(address),
1389                json!(amount),
1390                json!(comment),
1391                json!(comment_to),
1392                json!(subtractfeefromamount),
1393                json!(replaceable),
1394                json!(conf_target),
1395                json!(estimate_mode),
1396                json!(avoid_reuse),
1397                json!(fee_rate),
1398                json!(verbose),
1399            ],
1400        ));
1401        self
1402    }
1403
1404    /// Queue a `setban` RPC call
1405    pub fn setban(
1406        mut self,
1407        subnet: Value,
1408        command: Value,
1409        bantime: Value,
1410        absolute: Value,
1411    ) -> Self {
1412        self.calls
1413            .push(("setban", vec![json!(subnet), json!(command), json!(bantime), json!(absolute)]));
1414        self
1415    }
1416
1417    /// Queue a `setlabel` RPC call
1418    pub fn setlabel(mut self, address: Value, label: Value) -> Self {
1419        self.calls.push(("setlabel", vec![json!(address), json!(label)]));
1420        self
1421    }
1422
1423    /// Queue a `setmocktime` RPC call
1424    pub fn setmocktime(mut self, timestamp: Value) -> Self {
1425        self.calls.push(("setmocktime", vec![json!(timestamp)]));
1426        self
1427    }
1428
1429    /// Queue a `setnetworkactive` RPC call
1430    pub fn setnetworkactive(mut self, state: Value) -> Self {
1431        self.calls.push(("setnetworkactive", vec![json!(state)]));
1432        self
1433    }
1434
1435    /// Queue a `settxfee` RPC call
1436    pub fn settxfee(mut self, amount: Value) -> Self {
1437        self.calls.push(("settxfee", vec![json!(amount)]));
1438        self
1439    }
1440
1441    /// Queue a `setwalletflag` RPC call
1442    pub fn setwalletflag(mut self, flag: Value, value: Value) -> Self {
1443        self.calls.push(("setwalletflag", vec![json!(flag), json!(value)]));
1444        self
1445    }
1446
1447    /// Queue a `signmessage` RPC call
1448    pub fn signmessage(mut self, address: Value, message: Value) -> Self {
1449        self.calls.push(("signmessage", vec![json!(address), json!(message)]));
1450        self
1451    }
1452
1453    /// Queue a `signmessagewithprivkey` RPC call
1454    pub fn signmessagewithprivkey(mut self, privkey: Value, message: Value) -> Self {
1455        self.calls.push(("signmessagewithprivkey", vec![json!(privkey), json!(message)]));
1456        self
1457    }
1458
1459    /// Queue a `signrawtransactionwithkey` RPC call
1460    pub fn signrawtransactionwithkey(
1461        mut self,
1462        hexstring: Value,
1463        privkeys: Value,
1464        prevtxs: Value,
1465        sighashtype: Value,
1466    ) -> Self {
1467        self.calls.push((
1468            "signrawtransactionwithkey",
1469            vec![json!(hexstring), json!(privkeys), json!(prevtxs), json!(sighashtype)],
1470        ));
1471        self
1472    }
1473
1474    /// Queue a `signrawtransactionwithwallet` RPC call
1475    pub fn signrawtransactionwithwallet(
1476        mut self,
1477        hexstring: Value,
1478        prevtxs: Value,
1479        sighashtype: Value,
1480    ) -> Self {
1481        self.calls.push((
1482            "signrawtransactionwithwallet",
1483            vec![json!(hexstring), json!(prevtxs), json!(sighashtype)],
1484        ));
1485        self
1486    }
1487
1488    /// Queue a `simulaterawtransaction` RPC call
1489    pub fn simulaterawtransaction(mut self, rawtxs: Value, options: Value) -> Self {
1490        self.calls.push(("simulaterawtransaction", vec![json!(rawtxs), json!(options)]));
1491        self
1492    }
1493
1494    /// Queue a `stop` RPC call
1495    pub fn stop(mut self, wait: Value) -> Self {
1496        self.calls.push(("stop", vec![json!(wait)]));
1497        self
1498    }
1499
1500    /// Queue a `submitblock` RPC call
1501    pub fn submitblock(mut self, hexdata: Value, dummy: Value) -> Self {
1502        self.calls.push(("submitblock", vec![json!(hexdata), json!(dummy)]));
1503        self
1504    }
1505
1506    /// Queue a `submitheader` RPC call
1507    pub fn submitheader(mut self, hexdata: Value) -> Self {
1508        self.calls.push(("submitheader", vec![json!(hexdata)]));
1509        self
1510    }
1511
1512    /// Queue a `submitpackage` RPC call
1513    pub fn submitpackage(
1514        mut self,
1515        package: Value,
1516        maxfeerate: Value,
1517        maxburnamount: Value,
1518    ) -> Self {
1519        self.calls
1520            .push(("submitpackage", vec![json!(package), json!(maxfeerate), json!(maxburnamount)]));
1521        self
1522    }
1523
1524    /// Queue a `syncwithvalidationinterfacequeue` RPC call
1525    pub fn syncwithvalidationinterfacequeue(mut self) -> Self {
1526        self.calls.push(("syncwithvalidationinterfacequeue", Vec::new()));
1527        self
1528    }
1529
1530    /// Queue a `testmempoolaccept` RPC call
1531    pub fn testmempoolaccept(mut self, rawtxs: Value, maxfeerate: Value) -> Self {
1532        self.calls.push(("testmempoolaccept", vec![json!(rawtxs), json!(maxfeerate)]));
1533        self
1534    }
1535
1536    /// Queue a `unloadwallet` RPC call
1537    pub fn unloadwallet(mut self, wallet_name: Value, load_on_startup: Value) -> Self {
1538        self.calls.push(("unloadwallet", vec![json!(wallet_name), json!(load_on_startup)]));
1539        self
1540    }
1541
1542    /// Queue a `uptime` RPC call
1543    pub fn uptime(mut self) -> Self {
1544        self.calls.push(("uptime", Vec::new()));
1545        self
1546    }
1547
1548    /// Queue a `utxoupdatepsbt` RPC call
1549    pub fn utxoupdatepsbt(mut self, psbt: Value, descriptors: Value) -> Self {
1550        self.calls.push(("utxoupdatepsbt", vec![json!(psbt), json!(descriptors)]));
1551        self
1552    }
1553
1554    /// Queue a `validateaddress` RPC call
1555    pub fn validateaddress(mut self, address: Value) -> Self {
1556        self.calls.push(("validateaddress", vec![json!(address)]));
1557        self
1558    }
1559
1560    /// Queue a `verifychain` RPC call
1561    pub fn verifychain(mut self, checklevel: Value, nblocks: Value) -> Self {
1562        self.calls.push(("verifychain", vec![json!(checklevel), json!(nblocks)]));
1563        self
1564    }
1565
1566    /// Queue a `verifymessage` RPC call
1567    pub fn verifymessage(mut self, address: Value, signature: Value, message: Value) -> Self {
1568        self.calls.push(("verifymessage", vec![json!(address), json!(signature), json!(message)]));
1569        self
1570    }
1571
1572    /// Queue a `verifytxoutproof` RPC call
1573    pub fn verifytxoutproof(mut self, proof: Value) -> Self {
1574        self.calls.push(("verifytxoutproof", vec![json!(proof)]));
1575        self
1576    }
1577
1578    /// Queue a `waitforblock` RPC call
1579    pub fn waitforblock(mut self, blockhash: Value, timeout: Value) -> Self {
1580        self.calls.push(("waitforblock", vec![json!(blockhash), json!(timeout)]));
1581        self
1582    }
1583
1584    /// Queue a `waitforblockheight` RPC call
1585    pub fn waitforblockheight(mut self, height: Value, timeout: Value) -> Self {
1586        self.calls.push(("waitforblockheight", vec![json!(height), json!(timeout)]));
1587        self
1588    }
1589
1590    /// Queue a `waitfornewblock` RPC call
1591    pub fn waitfornewblock(mut self, timeout: Value, current_tip: Value) -> Self {
1592        self.calls.push(("waitfornewblock", vec![json!(timeout), json!(current_tip)]));
1593        self
1594    }
1595
1596    /// Queue a `walletcreatefundedpsbt` RPC call
1597    pub fn walletcreatefundedpsbt(
1598        mut self,
1599        inputs: Value,
1600        outputs: Value,
1601        locktime: Value,
1602        options: Value,
1603        bip32derivs: Value,
1604        version: Value,
1605    ) -> Self {
1606        self.calls.push((
1607            "walletcreatefundedpsbt",
1608            vec![
1609                json!(inputs),
1610                json!(outputs),
1611                json!(locktime),
1612                json!(options),
1613                json!(bip32derivs),
1614                json!(version),
1615            ],
1616        ));
1617        self
1618    }
1619
1620    /// Queue a `walletdisplayaddress` RPC call
1621    pub fn walletdisplayaddress(mut self, address: Value) -> Self {
1622        self.calls.push(("walletdisplayaddress", vec![json!(address)]));
1623        self
1624    }
1625
1626    /// Queue a `walletlock` RPC call
1627    pub fn walletlock(mut self) -> Self {
1628        self.calls.push(("walletlock", Vec::new()));
1629        self
1630    }
1631
1632    /// Queue a `walletpassphrase` RPC call
1633    pub fn walletpassphrase(mut self, passphrase: Value, timeout: Value) -> Self {
1634        self.calls.push(("walletpassphrase", vec![json!(passphrase), json!(timeout)]));
1635        self
1636    }
1637
1638    /// Queue a `walletpassphrasechange` RPC call
1639    pub fn walletpassphrasechange(mut self, oldpassphrase: Value, newpassphrase: Value) -> Self {
1640        self.calls
1641            .push(("walletpassphrasechange", vec![json!(oldpassphrase), json!(newpassphrase)]));
1642        self
1643    }
1644
1645    /// Queue a `walletprocesspsbt` RPC call
1646    pub fn walletprocesspsbt(
1647        mut self,
1648        psbt: Value,
1649        sign: Value,
1650        sighashtype: Value,
1651        bip32derivs: Value,
1652        finalize: Value,
1653    ) -> Self {
1654        self.calls.push((
1655            "walletprocesspsbt",
1656            vec![json!(psbt), json!(sign), json!(sighashtype), json!(bip32derivs), json!(finalize)],
1657        ));
1658        self
1659    }
1660
1661    /// Executes the batch and returns typed results
1662    pub async fn execute(self) -> Result<BatchResults, TransportError> {
1663        let BatchBuilder { tx, calls } = self;
1664        // queue all calls into the transport
1665        for (method, params) in &calls {
1666            std::mem::drop(tx.send_request(method, params));
1667        }
1668        let raw_results = tx.end_batch().await.map_err(|e| TransportError::Rpc(e.to_string()))?;
1669
1670        // Parse the raw results into our typed struct
1671        let mut results = BatchResults {
1672            abandontransaction: (),
1673            abortrescan: None,
1674            addconnection: None,
1675            addnode: (),
1676            addpeeraddress: None,
1677            analyzepsbt: None,
1678            backupwallet: (),
1679            bumpfee: None,
1680            clearbanned: (),
1681            combinepsbt: None,
1682            combinerawtransaction: None,
1683            converttopsbt: None,
1684            createmultisig: None,
1685            createpsbt: None,
1686            createrawtransaction: None,
1687            createwallet: None,
1688            createwalletdescriptor: None,
1689            decodepsbt: None,
1690            decoderawtransaction: None,
1691            decodescript: None,
1692            deriveaddresses: None,
1693            descriptorprocesspsbt: None,
1694            disconnectnode: (),
1695            dumptxoutset: None,
1696            echo: None,
1697            echoipc: None,
1698            echojson: None,
1699            encryptwallet: None,
1700            enumeratesigners: None,
1701            estimaterawfee: None,
1702            estimatesmartfee: None,
1703            finalizepsbt: None,
1704            fundrawtransaction: None,
1705            generate: (),
1706            generateblock: None,
1707            generatetoaddress: None,
1708            generatetodescriptor: None,
1709            getaddednodeinfo: None,
1710            getaddressesbylabel: None,
1711            getaddressinfo: None,
1712            getaddrmaninfo: None,
1713            getbalance: None,
1714            getbalances: None,
1715            getbestblockhash: None,
1716            getblock: None,
1717            getblockchaininfo: None,
1718            getblockcount: None,
1719            getblockfilter: None,
1720            getblockfrompeer: None,
1721            getblockhash: None,
1722            getblockheader: None,
1723            getblockstats: None,
1724            getblocktemplate: None,
1725            getchainstates: None,
1726            getchaintips: None,
1727            getchaintxstats: None,
1728            getconnectioncount: None,
1729            getdeploymentinfo: None,
1730            getdescriptoractivity: None,
1731            getdescriptorinfo: None,
1732            getdifficulty: None,
1733            gethdkeys: None,
1734            getindexinfo: None,
1735            getmemoryinfo: None,
1736            getmempoolancestors: None,
1737            getmempooldescendants: None,
1738            getmempoolentry: None,
1739            getmempoolinfo: None,
1740            getmininginfo: None,
1741            getnettotals: None,
1742            getnetworkhashps: None,
1743            getnetworkinfo: None,
1744            getnewaddress: None,
1745            getnodeaddresses: None,
1746            getorphantxs: None,
1747            getpeerinfo: None,
1748            getprioritisedtransactions: None,
1749            getrawaddrman: None,
1750            getrawchangeaddress: None,
1751            getrawmempool: None,
1752            getrawtransaction: None,
1753            getreceivedbyaddress: None,
1754            getreceivedbylabel: None,
1755            getrpcinfo: None,
1756            gettransaction: None,
1757            gettxout: None,
1758            gettxoutproof: None,
1759            gettxoutsetinfo: None,
1760            gettxspendingprevout: None,
1761            getwalletinfo: None,
1762            getzmqnotifications: None,
1763            help: None,
1764            importdescriptors: None,
1765            importmempool: None,
1766            importprunedfunds: (),
1767            invalidateblock: (),
1768            joinpsbts: None,
1769            keypoolrefill: (),
1770            listaddressgroupings: None,
1771            listbanned: None,
1772            listdescriptors: None,
1773            listlabels: None,
1774            listlockunspent: None,
1775            listreceivedbyaddress: None,
1776            listreceivedbylabel: None,
1777            listsinceblock: None,
1778            listtransactions: None,
1779            listunspent: None,
1780            listwalletdir: None,
1781            listwallets: None,
1782            loadtxoutset: None,
1783            loadwallet: None,
1784            lockunspent: None,
1785            logging: None,
1786            migratewallet: None,
1787            mockscheduler: (),
1788            ping: (),
1789            preciousblock: (),
1790            prioritisetransaction: None,
1791            pruneblockchain: None,
1792            psbtbumpfee: None,
1793            reconsiderblock: (),
1794            removeprunedfunds: (),
1795            rescanblockchain: None,
1796            restorewallet: None,
1797            savemempool: None,
1798            scanblocks: None,
1799            scantxoutset: None,
1800            schema: None,
1801            send: None,
1802            sendall: None,
1803            sendmany: None,
1804            sendmsgtopeer: None,
1805            sendrawtransaction: None,
1806            sendtoaddress: None,
1807            setban: (),
1808            setlabel: (),
1809            setmocktime: (),
1810            setnetworkactive: None,
1811            settxfee: None,
1812            setwalletflag: None,
1813            signmessage: None,
1814            signmessagewithprivkey: None,
1815            signrawtransactionwithkey: None,
1816            signrawtransactionwithwallet: None,
1817            simulaterawtransaction: None,
1818            stop: None,
1819            submitblock: None,
1820            submitheader: (),
1821            submitpackage: None,
1822            syncwithvalidationinterfacequeue: (),
1823            testmempoolaccept: None,
1824            unloadwallet: None,
1825            uptime: None,
1826            utxoupdatepsbt: None,
1827            validateaddress: None,
1828            verifychain: None,
1829            verifymessage: None,
1830            verifytxoutproof: None,
1831            waitforblock: None,
1832            waitforblockheight: None,
1833            waitfornewblock: None,
1834            walletcreatefundedpsbt: None,
1835            walletdisplayaddress: None,
1836            walletlock: (),
1837            walletpassphrase: (),
1838            walletpassphrasechange: (),
1839            walletprocesspsbt: None,
1840        };
1841
1842        // Populate the fields based on the actual calls made
1843        for (i, (method_name, _)) in calls.iter().enumerate() {
1844            match *method_name {
1845                "abandontransaction" => results.abandontransaction = (),
1846                "abortrescan" =>
1847                    results.abortrescan =
1848                        Some(serde_json::from_value::<AbortrescanResponse>(raw_results[i].clone())?),
1849                "addconnection" =>
1850                    results.addconnection = Some(serde_json::from_value::<AddconnectionResponse>(
1851                        raw_results[i].clone(),
1852                    )?),
1853                "addnode" => results.addnode = (),
1854                "addpeeraddress" =>
1855                    results.addpeeraddress = Some(serde_json::from_value::<AddpeeraddressResponse>(
1856                        raw_results[i].clone(),
1857                    )?),
1858                "analyzepsbt" =>
1859                    results.analyzepsbt =
1860                        Some(serde_json::from_value::<AnalyzepsbtResponse>(raw_results[i].clone())?),
1861                "backupwallet" => results.backupwallet = (),
1862                "bumpfee" =>
1863                    results.bumpfee =
1864                        Some(serde_json::from_value::<BumpfeeResponse>(raw_results[i].clone())?),
1865                "clearbanned" => results.clearbanned = (),
1866                "combinepsbt" =>
1867                    results.combinepsbt =
1868                        Some(serde_json::from_value::<CombinepsbtResponse>(raw_results[i].clone())?),
1869                "combinerawtransaction" =>
1870                    results.combinerawtransaction =
1871                        Some(serde_json::from_value::<CombinerawtransactionResponse>(
1872                            raw_results[i].clone(),
1873                        )?),
1874                "converttopsbt" =>
1875                    results.converttopsbt = Some(serde_json::from_value::<ConverttopsbtResponse>(
1876                        raw_results[i].clone(),
1877                    )?),
1878                "createmultisig" =>
1879                    results.createmultisig = Some(serde_json::from_value::<CreatemultisigResponse>(
1880                        raw_results[i].clone(),
1881                    )?),
1882                "createpsbt" =>
1883                    results.createpsbt =
1884                        Some(serde_json::from_value::<CreatepsbtResponse>(raw_results[i].clone())?),
1885                "createrawtransaction" =>
1886                    results.createrawtransaction =
1887                        Some(serde_json::from_value::<CreaterawtransactionResponse>(
1888                            raw_results[i].clone(),
1889                        )?),
1890                "createwallet" =>
1891                    results.createwallet = Some(serde_json::from_value::<CreatewalletResponse>(
1892                        raw_results[i].clone(),
1893                    )?),
1894                "createwalletdescriptor" =>
1895                    results.createwalletdescriptor =
1896                        Some(serde_json::from_value::<CreatewalletdescriptorResponse>(
1897                            raw_results[i].clone(),
1898                        )?),
1899                "decodepsbt" =>
1900                    results.decodepsbt =
1901                        Some(serde_json::from_value::<DecodepsbtResponse>(raw_results[i].clone())?),
1902                "decoderawtransaction" =>
1903                    results.decoderawtransaction =
1904                        Some(serde_json::from_value::<DecoderawtransactionResponse>(
1905                            raw_results[i].clone(),
1906                        )?),
1907                "decodescript" =>
1908                    results.decodescript = Some(serde_json::from_value::<DecodescriptResponse>(
1909                        raw_results[i].clone(),
1910                    )?),
1911                "deriveaddresses" =>
1912                    results.deriveaddresses = Some(
1913                        serde_json::from_value::<DeriveaddressesResponse>(raw_results[i].clone())?,
1914                    ),
1915                "descriptorprocesspsbt" =>
1916                    results.descriptorprocesspsbt =
1917                        Some(serde_json::from_value::<DescriptorprocesspsbtResponse>(
1918                            raw_results[i].clone(),
1919                        )?),
1920                "disconnectnode" => results.disconnectnode = (),
1921                "dumptxoutset" =>
1922                    results.dumptxoutset = Some(serde_json::from_value::<DumptxoutsetResponse>(
1923                        raw_results[i].clone(),
1924                    )?),
1925                "echo" =>
1926                    results.echo =
1927                        Some(serde_json::from_value::<EchoResponse>(raw_results[i].clone())?),
1928                "echoipc" =>
1929                    results.echoipc =
1930                        Some(serde_json::from_value::<EchoipcResponse>(raw_results[i].clone())?),
1931                "echojson" =>
1932                    results.echojson =
1933                        Some(serde_json::from_value::<EchojsonResponse>(raw_results[i].clone())?),
1934                "encryptwallet" =>
1935                    results.encryptwallet = Some(serde_json::from_value::<EncryptwalletResponse>(
1936                        raw_results[i].clone(),
1937                    )?),
1938                "enumeratesigners" =>
1939                    results.enumeratesigners = Some(serde_json::from_value::<
1940                        EnumeratesignersResponse,
1941                    >(raw_results[i].clone())?),
1942                "estimaterawfee" =>
1943                    results.estimaterawfee = Some(serde_json::from_value::<EstimaterawfeeResponse>(
1944                        raw_results[i].clone(),
1945                    )?),
1946                "estimatesmartfee" =>
1947                    results.estimatesmartfee = Some(serde_json::from_value::<
1948                        EstimatesmartfeeResponse,
1949                    >(raw_results[i].clone())?),
1950                "finalizepsbt" =>
1951                    results.finalizepsbt = Some(serde_json::from_value::<FinalizepsbtResponse>(
1952                        raw_results[i].clone(),
1953                    )?),
1954                "fundrawtransaction" =>
1955                    results.fundrawtransaction = Some(serde_json::from_value::<
1956                        FundrawtransactionResponse,
1957                    >(raw_results[i].clone())?),
1958                "generate" => results.generate = (),
1959                "generateblock" =>
1960                    results.generateblock = Some(serde_json::from_value::<GenerateblockResponse>(
1961                        raw_results[i].clone(),
1962                    )?),
1963                "generatetoaddress" =>
1964                    results.generatetoaddress = Some(serde_json::from_value::<
1965                        GeneratetoaddressResponse,
1966                    >(raw_results[i].clone())?),
1967                "generatetodescriptor" =>
1968                    results.generatetodescriptor =
1969                        Some(serde_json::from_value::<GeneratetodescriptorResponse>(
1970                            raw_results[i].clone(),
1971                        )?),
1972                "getaddednodeinfo" =>
1973                    results.getaddednodeinfo = Some(serde_json::from_value::<
1974                        GetaddednodeinfoResponse,
1975                    >(raw_results[i].clone())?),
1976                "getaddressesbylabel" =>
1977                    results.getaddressesbylabel =
1978                        Some(serde_json::from_value::<GetaddressesbylabelResponse>(
1979                            raw_results[i].clone(),
1980                        )?),
1981                "getaddressinfo" =>
1982                    results.getaddressinfo = Some(serde_json::from_value::<GetaddressinfoResponse>(
1983                        raw_results[i].clone(),
1984                    )?),
1985                "getaddrmaninfo" =>
1986                    results.getaddrmaninfo = Some(serde_json::from_value::<GetaddrmaninfoResponse>(
1987                        raw_results[i].clone(),
1988                    )?),
1989                "getbalance" =>
1990                    results.getbalance =
1991                        Some(serde_json::from_value::<GetbalanceResponse>(raw_results[i].clone())?),
1992                "getbalances" =>
1993                    results.getbalances =
1994                        Some(serde_json::from_value::<GetbalancesResponse>(raw_results[i].clone())?),
1995                "getbestblockhash" =>
1996                    results.getbestblockhash = Some(serde_json::from_value::<
1997                        GetbestblockhashResponse,
1998                    >(raw_results[i].clone())?),
1999                "getblock" =>
2000                    results.getblock =
2001                        Some(serde_json::from_value::<GetblockResponse>(raw_results[i].clone())?),
2002                "getblockchaininfo" =>
2003                    results.getblockchaininfo = Some(serde_json::from_value::<
2004                        GetblockchaininfoResponse,
2005                    >(raw_results[i].clone())?),
2006                "getblockcount" =>
2007                    results.getblockcount = Some(serde_json::from_value::<GetblockcountResponse>(
2008                        raw_results[i].clone(),
2009                    )?),
2010                "getblockfilter" =>
2011                    results.getblockfilter = Some(serde_json::from_value::<GetblockfilterResponse>(
2012                        raw_results[i].clone(),
2013                    )?),
2014                "getblockfrompeer" =>
2015                    results.getblockfrompeer = Some(serde_json::from_value::<
2016                        GetblockfrompeerResponse,
2017                    >(raw_results[i].clone())?),
2018                "getblockhash" =>
2019                    results.getblockhash = Some(serde_json::from_value::<GetblockhashResponse>(
2020                        raw_results[i].clone(),
2021                    )?),
2022                "getblockheader" =>
2023                    results.getblockheader = Some(serde_json::from_value::<GetblockheaderResponse>(
2024                        raw_results[i].clone(),
2025                    )?),
2026                "getblockstats" =>
2027                    results.getblockstats = Some(serde_json::from_value::<GetblockstatsResponse>(
2028                        raw_results[i].clone(),
2029                    )?),
2030                "getblocktemplate" =>
2031                    results.getblocktemplate = Some(serde_json::from_value::<
2032                        GetblocktemplateResponse,
2033                    >(raw_results[i].clone())?),
2034                "getchainstates" =>
2035                    results.getchainstates = Some(serde_json::from_value::<GetchainstatesResponse>(
2036                        raw_results[i].clone(),
2037                    )?),
2038                "getchaintips" =>
2039                    results.getchaintips = Some(serde_json::from_value::<GetchaintipsResponse>(
2040                        raw_results[i].clone(),
2041                    )?),
2042                "getchaintxstats" =>
2043                    results.getchaintxstats = Some(
2044                        serde_json::from_value::<GetchaintxstatsResponse>(raw_results[i].clone())?,
2045                    ),
2046                "getconnectioncount" =>
2047                    results.getconnectioncount = Some(serde_json::from_value::<
2048                        GetconnectioncountResponse,
2049                    >(raw_results[i].clone())?),
2050                "getdeploymentinfo" =>
2051                    results.getdeploymentinfo = Some(serde_json::from_value::<
2052                        GetdeploymentinfoResponse,
2053                    >(raw_results[i].clone())?),
2054                "getdescriptoractivity" =>
2055                    results.getdescriptoractivity =
2056                        Some(serde_json::from_value::<GetdescriptoractivityResponse>(
2057                            raw_results[i].clone(),
2058                        )?),
2059                "getdescriptorinfo" =>
2060                    results.getdescriptorinfo = Some(serde_json::from_value::<
2061                        GetdescriptorinfoResponse,
2062                    >(raw_results[i].clone())?),
2063                "getdifficulty" =>
2064                    results.getdifficulty = Some(serde_json::from_value::<GetdifficultyResponse>(
2065                        raw_results[i].clone(),
2066                    )?),
2067                "gethdkeys" =>
2068                    results.gethdkeys =
2069                        Some(serde_json::from_value::<GethdkeysResponse>(raw_results[i].clone())?),
2070                "getindexinfo" =>
2071                    results.getindexinfo = Some(serde_json::from_value::<GetindexinfoResponse>(
2072                        raw_results[i].clone(),
2073                    )?),
2074                "getmemoryinfo" =>
2075                    results.getmemoryinfo = Some(serde_json::from_value::<GetmemoryinfoResponse>(
2076                        raw_results[i].clone(),
2077                    )?),
2078                "getmempoolancestors" =>
2079                    results.getmempoolancestors =
2080                        Some(serde_json::from_value::<GetmempoolancestorsResponse>(
2081                            raw_results[i].clone(),
2082                        )?),
2083                "getmempooldescendants" =>
2084                    results.getmempooldescendants =
2085                        Some(serde_json::from_value::<GetmempooldescendantsResponse>(
2086                            raw_results[i].clone(),
2087                        )?),
2088                "getmempoolentry" =>
2089                    results.getmempoolentry = Some(
2090                        serde_json::from_value::<GetmempoolentryResponse>(raw_results[i].clone())?,
2091                    ),
2092                "getmempoolinfo" =>
2093                    results.getmempoolinfo = Some(serde_json::from_value::<GetmempoolinfoResponse>(
2094                        raw_results[i].clone(),
2095                    )?),
2096                "getmininginfo" =>
2097                    results.getmininginfo = Some(serde_json::from_value::<GetmininginfoResponse>(
2098                        raw_results[i].clone(),
2099                    )?),
2100                "getnettotals" =>
2101                    results.getnettotals = Some(serde_json::from_value::<GetnettotalsResponse>(
2102                        raw_results[i].clone(),
2103                    )?),
2104                "getnetworkhashps" =>
2105                    results.getnetworkhashps = Some(serde_json::from_value::<
2106                        GetnetworkhashpsResponse,
2107                    >(raw_results[i].clone())?),
2108                "getnetworkinfo" =>
2109                    results.getnetworkinfo = Some(serde_json::from_value::<GetnetworkinfoResponse>(
2110                        raw_results[i].clone(),
2111                    )?),
2112                "getnewaddress" =>
2113                    results.getnewaddress = Some(serde_json::from_value::<GetnewaddressResponse>(
2114                        raw_results[i].clone(),
2115                    )?),
2116                "getnodeaddresses" =>
2117                    results.getnodeaddresses = Some(serde_json::from_value::<
2118                        GetnodeaddressesResponse,
2119                    >(raw_results[i].clone())?),
2120                "getorphantxs" =>
2121                    results.getorphantxs = Some(serde_json::from_value::<GetorphantxsResponse>(
2122                        raw_results[i].clone(),
2123                    )?),
2124                "getpeerinfo" =>
2125                    results.getpeerinfo =
2126                        Some(serde_json::from_value::<GetpeerinfoResponse>(raw_results[i].clone())?),
2127                "getprioritisedtransactions" =>
2128                    results.getprioritisedtransactions =
2129                        Some(serde_json::from_value::<GetprioritisedtransactionsResponse>(
2130                            raw_results[i].clone(),
2131                        )?),
2132                "getrawaddrman" =>
2133                    results.getrawaddrman = Some(serde_json::from_value::<GetrawaddrmanResponse>(
2134                        raw_results[i].clone(),
2135                    )?),
2136                "getrawchangeaddress" =>
2137                    results.getrawchangeaddress =
2138                        Some(serde_json::from_value::<GetrawchangeaddressResponse>(
2139                            raw_results[i].clone(),
2140                        )?),
2141                "getrawmempool" =>
2142                    results.getrawmempool = Some(serde_json::from_value::<GetrawmempoolResponse>(
2143                        raw_results[i].clone(),
2144                    )?),
2145                "getrawtransaction" =>
2146                    results.getrawtransaction = Some(serde_json::from_value::<
2147                        GetrawtransactionResponse,
2148                    >(raw_results[i].clone())?),
2149                "getreceivedbyaddress" =>
2150                    results.getreceivedbyaddress =
2151                        Some(serde_json::from_value::<GetreceivedbyaddressResponse>(
2152                            raw_results[i].clone(),
2153                        )?),
2154                "getreceivedbylabel" =>
2155                    results.getreceivedbylabel = Some(serde_json::from_value::<
2156                        GetreceivedbylabelResponse,
2157                    >(raw_results[i].clone())?),
2158                "getrpcinfo" =>
2159                    results.getrpcinfo =
2160                        Some(serde_json::from_value::<GetrpcinfoResponse>(raw_results[i].clone())?),
2161                "gettransaction" =>
2162                    results.gettransaction = Some(serde_json::from_value::<GettransactionResponse>(
2163                        raw_results[i].clone(),
2164                    )?),
2165                "gettxout" =>
2166                    results.gettxout =
2167                        Some(serde_json::from_value::<GettxoutResponse>(raw_results[i].clone())?),
2168                "gettxoutproof" =>
2169                    results.gettxoutproof = Some(serde_json::from_value::<GettxoutproofResponse>(
2170                        raw_results[i].clone(),
2171                    )?),
2172                "gettxoutsetinfo" =>
2173                    results.gettxoutsetinfo = Some(
2174                        serde_json::from_value::<GettxoutsetinfoResponse>(raw_results[i].clone())?,
2175                    ),
2176                "gettxspendingprevout" =>
2177                    results.gettxspendingprevout =
2178                        Some(serde_json::from_value::<GettxspendingprevoutResponse>(
2179                            raw_results[i].clone(),
2180                        )?),
2181                "getwalletinfo" =>
2182                    results.getwalletinfo = Some(serde_json::from_value::<GetwalletinfoResponse>(
2183                        raw_results[i].clone(),
2184                    )?),
2185                "getzmqnotifications" =>
2186                    results.getzmqnotifications =
2187                        Some(serde_json::from_value::<GetzmqnotificationsResponse>(
2188                            raw_results[i].clone(),
2189                        )?),
2190                "help" =>
2191                    results.help =
2192                        Some(serde_json::from_value::<HelpResponse>(raw_results[i].clone())?),
2193                "importdescriptors" =>
2194                    results.importdescriptors = Some(serde_json::from_value::<
2195                        ImportdescriptorsResponse,
2196                    >(raw_results[i].clone())?),
2197                "importmempool" =>
2198                    results.importmempool = Some(serde_json::from_value::<ImportmempoolResponse>(
2199                        raw_results[i].clone(),
2200                    )?),
2201                "importprunedfunds" => results.importprunedfunds = (),
2202                "invalidateblock" => results.invalidateblock = (),
2203                "joinpsbts" =>
2204                    results.joinpsbts =
2205                        Some(serde_json::from_value::<JoinpsbtsResponse>(raw_results[i].clone())?),
2206                "keypoolrefill" => results.keypoolrefill = (),
2207                "listaddressgroupings" =>
2208                    results.listaddressgroupings =
2209                        Some(serde_json::from_value::<ListaddressgroupingsResponse>(
2210                            raw_results[i].clone(),
2211                        )?),
2212                "listbanned" =>
2213                    results.listbanned =
2214                        Some(serde_json::from_value::<ListbannedResponse>(raw_results[i].clone())?),
2215                "listdescriptors" =>
2216                    results.listdescriptors = Some(
2217                        serde_json::from_value::<ListdescriptorsResponse>(raw_results[i].clone())?,
2218                    ),
2219                "listlabels" =>
2220                    results.listlabels =
2221                        Some(serde_json::from_value::<ListlabelsResponse>(raw_results[i].clone())?),
2222                "listlockunspent" =>
2223                    results.listlockunspent = Some(
2224                        serde_json::from_value::<ListlockunspentResponse>(raw_results[i].clone())?,
2225                    ),
2226                "listreceivedbyaddress" =>
2227                    results.listreceivedbyaddress =
2228                        Some(serde_json::from_value::<ListreceivedbyaddressResponse>(
2229                            raw_results[i].clone(),
2230                        )?),
2231                "listreceivedbylabel" =>
2232                    results.listreceivedbylabel =
2233                        Some(serde_json::from_value::<ListreceivedbylabelResponse>(
2234                            raw_results[i].clone(),
2235                        )?),
2236                "listsinceblock" =>
2237                    results.listsinceblock = Some(serde_json::from_value::<ListsinceblockResponse>(
2238                        raw_results[i].clone(),
2239                    )?),
2240                "listtransactions" =>
2241                    results.listtransactions = Some(serde_json::from_value::<
2242                        ListtransactionsResponse,
2243                    >(raw_results[i].clone())?),
2244                "listunspent" =>
2245                    results.listunspent =
2246                        Some(serde_json::from_value::<ListunspentResponse>(raw_results[i].clone())?),
2247                "listwalletdir" =>
2248                    results.listwalletdir = Some(serde_json::from_value::<ListwalletdirResponse>(
2249                        raw_results[i].clone(),
2250                    )?),
2251                "listwallets" =>
2252                    results.listwallets =
2253                        Some(serde_json::from_value::<ListwalletsResponse>(raw_results[i].clone())?),
2254                "loadtxoutset" =>
2255                    results.loadtxoutset = Some(serde_json::from_value::<LoadtxoutsetResponse>(
2256                        raw_results[i].clone(),
2257                    )?),
2258                "loadwallet" =>
2259                    results.loadwallet =
2260                        Some(serde_json::from_value::<LoadwalletResponse>(raw_results[i].clone())?),
2261                "lockunspent" =>
2262                    results.lockunspent =
2263                        Some(serde_json::from_value::<LockunspentResponse>(raw_results[i].clone())?),
2264                "logging" =>
2265                    results.logging =
2266                        Some(serde_json::from_value::<LoggingResponse>(raw_results[i].clone())?),
2267                "migratewallet" =>
2268                    results.migratewallet = Some(serde_json::from_value::<MigratewalletResponse>(
2269                        raw_results[i].clone(),
2270                    )?),
2271                "mockscheduler" => results.mockscheduler = (),
2272                "ping" => results.ping = (),
2273                "preciousblock" => results.preciousblock = (),
2274                "prioritisetransaction" =>
2275                    results.prioritisetransaction =
2276                        Some(serde_json::from_value::<PrioritisetransactionResponse>(
2277                            raw_results[i].clone(),
2278                        )?),
2279                "pruneblockchain" =>
2280                    results.pruneblockchain = Some(
2281                        serde_json::from_value::<PruneblockchainResponse>(raw_results[i].clone())?,
2282                    ),
2283                "psbtbumpfee" =>
2284                    results.psbtbumpfee =
2285                        Some(serde_json::from_value::<PsbtbumpfeeResponse>(raw_results[i].clone())?),
2286                "reconsiderblock" => results.reconsiderblock = (),
2287                "removeprunedfunds" => results.removeprunedfunds = (),
2288                "rescanblockchain" =>
2289                    results.rescanblockchain = Some(serde_json::from_value::<
2290                        RescanblockchainResponse,
2291                    >(raw_results[i].clone())?),
2292                "restorewallet" =>
2293                    results.restorewallet = Some(serde_json::from_value::<RestorewalletResponse>(
2294                        raw_results[i].clone(),
2295                    )?),
2296                "savemempool" =>
2297                    results.savemempool =
2298                        Some(serde_json::from_value::<SavemempoolResponse>(raw_results[i].clone())?),
2299                "scanblocks" =>
2300                    results.scanblocks =
2301                        Some(serde_json::from_value::<ScanblocksResponse>(raw_results[i].clone())?),
2302                "scantxoutset" =>
2303                    results.scantxoutset = Some(serde_json::from_value::<ScantxoutsetResponse>(
2304                        raw_results[i].clone(),
2305                    )?),
2306                "schema" =>
2307                    results.schema =
2308                        Some(serde_json::from_value::<SchemaResponse>(raw_results[i].clone())?),
2309                "send" =>
2310                    results.send =
2311                        Some(serde_json::from_value::<SendResponse>(raw_results[i].clone())?),
2312                "sendall" =>
2313                    results.sendall =
2314                        Some(serde_json::from_value::<SendallResponse>(raw_results[i].clone())?),
2315                "sendmany" =>
2316                    results.sendmany =
2317                        Some(serde_json::from_value::<SendmanyResponse>(raw_results[i].clone())?),
2318                "sendmsgtopeer" =>
2319                    results.sendmsgtopeer = Some(serde_json::from_value::<SendmsgtopeerResponse>(
2320                        raw_results[i].clone(),
2321                    )?),
2322                "sendrawtransaction" =>
2323                    results.sendrawtransaction = Some(serde_json::from_value::<
2324                        SendrawtransactionResponse,
2325                    >(raw_results[i].clone())?),
2326                "sendtoaddress" =>
2327                    results.sendtoaddress = Some(serde_json::from_value::<SendtoaddressResponse>(
2328                        raw_results[i].clone(),
2329                    )?),
2330                "setban" => results.setban = (),
2331                "setlabel" => results.setlabel = (),
2332                "setmocktime" => results.setmocktime = (),
2333                "setnetworkactive" =>
2334                    results.setnetworkactive = Some(serde_json::from_value::<
2335                        SetnetworkactiveResponse,
2336                    >(raw_results[i].clone())?),
2337                "settxfee" =>
2338                    results.settxfee =
2339                        Some(serde_json::from_value::<SettxfeeResponse>(raw_results[i].clone())?),
2340                "setwalletflag" =>
2341                    results.setwalletflag = Some(serde_json::from_value::<SetwalletflagResponse>(
2342                        raw_results[i].clone(),
2343                    )?),
2344                "signmessage" =>
2345                    results.signmessage =
2346                        Some(serde_json::from_value::<SignmessageResponse>(raw_results[i].clone())?),
2347                "signmessagewithprivkey" =>
2348                    results.signmessagewithprivkey =
2349                        Some(serde_json::from_value::<SignmessagewithprivkeyResponse>(
2350                            raw_results[i].clone(),
2351                        )?),
2352                "signrawtransactionwithkey" =>
2353                    results.signrawtransactionwithkey =
2354                        Some(serde_json::from_value::<SignrawtransactionwithkeyResponse>(
2355                            raw_results[i].clone(),
2356                        )?),
2357                "signrawtransactionwithwallet" =>
2358                    results.signrawtransactionwithwallet =
2359                        Some(serde_json::from_value::<SignrawtransactionwithwalletResponse>(
2360                            raw_results[i].clone(),
2361                        )?),
2362                "simulaterawtransaction" =>
2363                    results.simulaterawtransaction =
2364                        Some(serde_json::from_value::<SimulaterawtransactionResponse>(
2365                            raw_results[i].clone(),
2366                        )?),
2367                "stop" =>
2368                    results.stop =
2369                        Some(serde_json::from_value::<StopResponse>(raw_results[i].clone())?),
2370                "submitblock" =>
2371                    results.submitblock =
2372                        Some(serde_json::from_value::<SubmitblockResponse>(raw_results[i].clone())?),
2373                "submitheader" => results.submitheader = (),
2374                "submitpackage" =>
2375                    results.submitpackage = Some(serde_json::from_value::<SubmitpackageResponse>(
2376                        raw_results[i].clone(),
2377                    )?),
2378                "syncwithvalidationinterfacequeue" => results.syncwithvalidationinterfacequeue = (),
2379                "testmempoolaccept" =>
2380                    results.testmempoolaccept = Some(serde_json::from_value::<
2381                        TestmempoolacceptResponse,
2382                    >(raw_results[i].clone())?),
2383                "unloadwallet" =>
2384                    results.unloadwallet = Some(serde_json::from_value::<UnloadwalletResponse>(
2385                        raw_results[i].clone(),
2386                    )?),
2387                "uptime" =>
2388                    results.uptime =
2389                        Some(serde_json::from_value::<UptimeResponse>(raw_results[i].clone())?),
2390                "utxoupdatepsbt" =>
2391                    results.utxoupdatepsbt = Some(serde_json::from_value::<UtxoupdatepsbtResponse>(
2392                        raw_results[i].clone(),
2393                    )?),
2394                "validateaddress" =>
2395                    results.validateaddress = Some(
2396                        serde_json::from_value::<ValidateaddressResponse>(raw_results[i].clone())?,
2397                    ),
2398                "verifychain" =>
2399                    results.verifychain =
2400                        Some(serde_json::from_value::<VerifychainResponse>(raw_results[i].clone())?),
2401                "verifymessage" =>
2402                    results.verifymessage = Some(serde_json::from_value::<VerifymessageResponse>(
2403                        raw_results[i].clone(),
2404                    )?),
2405                "verifytxoutproof" =>
2406                    results.verifytxoutproof = Some(serde_json::from_value::<
2407                        VerifytxoutproofResponse,
2408                    >(raw_results[i].clone())?),
2409                "waitforblock" =>
2410                    results.waitforblock = Some(serde_json::from_value::<WaitforblockResponse>(
2411                        raw_results[i].clone(),
2412                    )?),
2413                "waitforblockheight" =>
2414                    results.waitforblockheight = Some(serde_json::from_value::<
2415                        WaitforblockheightResponse,
2416                    >(raw_results[i].clone())?),
2417                "waitfornewblock" =>
2418                    results.waitfornewblock = Some(
2419                        serde_json::from_value::<WaitfornewblockResponse>(raw_results[i].clone())?,
2420                    ),
2421                "walletcreatefundedpsbt" =>
2422                    results.walletcreatefundedpsbt =
2423                        Some(serde_json::from_value::<WalletcreatefundedpsbtResponse>(
2424                            raw_results[i].clone(),
2425                        )?),
2426                "walletdisplayaddress" =>
2427                    results.walletdisplayaddress =
2428                        Some(serde_json::from_value::<WalletdisplayaddressResponse>(
2429                            raw_results[i].clone(),
2430                        )?),
2431                "walletlock" => results.walletlock = (),
2432                "walletpassphrase" => results.walletpassphrase = (),
2433                "walletpassphrasechange" => results.walletpassphrasechange = (),
2434                "walletprocesspsbt" =>
2435                    results.walletprocesspsbt = Some(serde_json::from_value::<
2436                        WalletprocesspsbtResponse,
2437                    >(raw_results[i].clone())?),
2438                _ => return Err(TransportError::Rpc(format!("Unknown method: {}", method_name))),
2439            }
2440        }
2441
2442        Ok(results)
2443    }
2444}