Skip to main content

ethos_bitcoind/client_trait/
client.rs

1// Generated client trait for Bitcoin Core v30.2
2
3use std::future::Future;
4
5use async_trait::async_trait;
6use serde::de::DeserializeOwned;
7
8use crate::transport::core::TransportExt;
9use crate::transport::{TransportError, TransportTrait};
10use crate::types::*;
11
12#[doc = r#"A versioned client trait for Bitcoin Core v30.2"#]
13#[async_trait]
14pub trait BitcoinClient: Send + Sync + TransportTrait + TransportExt + RpcDispatchExt {
15    type Error;
16
17    /// Mark in-wallet transaction <txid> as abandoned
18    /// This will mark this transaction and all its in-wallet descendants as abandoned which will allow
19    /// for their inputs to be respent.  It can be used to replace "stuck" or evicted transactions.
20    /// It only works on transactions which are not included in a block and are not currently in the mempool.
21    /// It has no effect on transactions which are already abandoned.
22    async fn abandon_transaction(
23        &self,
24        txid: bitcoin::Txid,
25    ) -> Result<AbandonTransactionResponse, Self::Error>;
26
27    /// Stops current wallet rescan triggered by an RPC call, e.g. by a rescanblockchain call.
28    /// Note: Use "getwalletinfo" to query the scanning progress.
29    async fn abort_rescan(&self) -> Result<AbortRescanResponse, Self::Error>;
30
31    /// Open an outbound connection to a specified node. This RPC is for testing only.
32    async fn add_connection(
33        &self,
34        address: bitcoin::Address,
35        connection_type: String,
36        v2transport: bool,
37    ) -> Result<AddConnectionResponse, Self::Error>;
38
39    /// Attempts to add or remove a node from the addnode list.
40    /// Or try a connection to a node once.
41    /// Nodes added using addnode (or -connect) are protected from DoS disconnection and are not required to be
42    /// full nodes/support SegWit as other outbound peers are (though such peers will not be synced from).
43    /// Addnode connections are limited to 8 at a time and are counted separately from the -maxconnections limit.
44    async fn add_node(
45        &self,
46        node: String,
47        command: String,
48        v2transport: Option<bool>,
49    ) -> Result<AddNodeResponse, Self::Error>;
50
51    /// Add the address of a potential peer to an address manager table. This RPC is for testing only.
52    async fn add_peer_address(
53        &self,
54        address: bitcoin::Address,
55        port: i64,
56        tried: Option<bool>,
57    ) -> Result<AddPeerAddressResponse, Self::Error>;
58
59    /// Analyzes and provides information about the current status of a PSBT and its inputs
60    async fn analyze_psbt(&self, psbt: String) -> Result<AnalyzePsbtResponse, Self::Error>;
61
62    /// Safely copies the current wallet file to the specified destination, which can either be a directory or a path with a filename.
63    async fn backup_wallet(&self, destination: String)
64        -> Result<BackupWalletResponse, Self::Error>;
65
66    /// Bumps the fee of a transaction T, replacing it with a new transaction B.
67    /// A transaction with the given txid must be in the wallet.
68    /// The command will pay the additional fee by reducing change outputs or adding inputs when necessary.
69    /// It may add a new change output if one does not already exist.
70    /// All inputs in the original transaction will be included in the replacement transaction.
71    /// The command will fail if the wallet or mempool contains a transaction that spends one of T's outputs.
72    /// By default, the new fee will be calculated automatically using the estimatesmartfee RPC.
73    /// The user can specify a confirmation target for estimatesmartfee.
74    /// Alternatively, the user can specify a fee rate in sat/vB for the new transaction.
75    /// At a minimum, the new fee rate must be high enough to pay an additional new relay fee (incrementalfee
76    /// returned by getnetworkinfo) to enter the node's mempool.
77    /// * WARNING: before version 0.21, fee_rate was in BTC/kvB. As of 0.21, fee_rate is in sat/vB. *
78    async fn bump_fee(
79        &self,
80        txid: bitcoin::Txid,
81        options: Option<serde_json::Value>,
82    ) -> Result<BumpFeeResponse, Self::Error>;
83
84    /// Clear all banned IPs.
85    async fn clear_banned(&self) -> Result<ClearBannedResponse, Self::Error>;
86
87    /// Combine multiple partially signed Bitcoin transactions into one transaction.
88    /// Implements the Combiner role.
89    async fn combine_psbt(
90        &self,
91        txs: Vec<serde_json::Value>,
92    ) -> Result<CombinePsbtResponse, Self::Error>;
93
94    /// Combine multiple partially signed transactions into one transaction.
95    /// The combined transaction may be another partially signed transaction or a
96    /// fully signed transaction.
97    async fn combine_raw_transaction(
98        &self,
99        txs: Vec<serde_json::Value>,
100    ) -> Result<CombineRawTransactionResponse, Self::Error>;
101
102    /// Converts a network serialized transaction to a PSBT. This should be used only with createrawtransaction and fundrawtransaction
103    /// createpsbt and walletcreatefundedpsbt should be used for new applications.
104    async fn convert_to_psbt(
105        &self,
106        hexstring: String,
107        permitsigdata: Option<bool>,
108        iswitness: Option<bool>,
109    ) -> Result<ConvertToPsbtResponse, Self::Error>;
110
111    /// Creates a multi-signature address with n signatures of m keys required.
112    /// It returns a json object with the address and redeemScript.
113    async fn create_multisig(
114        &self,
115        nrequired: i64,
116        keys: Vec<serde_json::Value>,
117        address_type: Option<String>,
118    ) -> Result<CreateMultisigResponse, Self::Error>;
119
120    /// Creates a transaction in the Partially Signed Transaction format.
121    /// Implements the Creator role.
122    /// Note that the transaction's inputs are not signed, and
123    /// it is not stored in the wallet or transmitted to the network.
124    async fn create_psbt(
125        &self,
126        inputs: Vec<serde_json::Value>,
127        outputs: Vec<serde_json::Value>,
128        locktime: Option<i64>,
129        replaceable: Option<bool>,
130        version: Option<i64>,
131    ) -> Result<CreatePsbtResponse, Self::Error>;
132
133    /// Create a transaction spending the given inputs and creating new outputs.
134    /// Outputs can be addresses or data.
135    /// Returns hex-encoded raw transaction.
136    /// Note that the transaction's inputs are not signed, and
137    /// it is not stored in the wallet or transmitted to the network.
138    async fn create_raw_transaction(
139        &self,
140        inputs: Vec<serde_json::Value>,
141        outputs: Vec<serde_json::Value>,
142        locktime: Option<i64>,
143        replaceable: Option<bool>,
144        version: Option<i64>,
145    ) -> Result<CreateRawTransactionResponse, Self::Error>;
146
147    /// Creates and loads a new wallet.
148    async fn create_wallet(
149        &self,
150        wallet_name: String,
151        disable_private_keys: Option<bool>,
152        blank: Option<bool>,
153        passphrase: Option<String>,
154        avoid_reuse: Option<bool>,
155        descriptors: Option<bool>,
156        load_on_startup: Option<bool>,
157        external_signer: Option<bool>,
158    ) -> Result<CreateWalletResponse, Self::Error>;
159
160    /// Creates the wallet's descriptor for the given address type. The address type must be one that the wallet does not already have a descriptor for.
161    /// Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.
162    async fn create_wallet_descriptor(
163        &self,
164        r#type: String,
165        options: Option<serde_json::Value>,
166    ) -> Result<CreateWalletDescriptorResponse, Self::Error>;
167
168    /// Return a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction.
169    async fn decode_psbt(&self, psbt: String) -> Result<DecodePsbtResponse, Self::Error>;
170
171    /// Return a JSON object representing the serialized, hex-encoded transaction.
172    async fn decode_raw_transaction(
173        &self,
174        hexstring: String,
175        iswitness: Option<bool>,
176    ) -> Result<DecodeRawTransactionResponse, Self::Error>;
177
178    /// Decode a hex-encoded script.
179    async fn decode_script(&self, hexstring: String) -> Result<DecodeScriptResponse, Self::Error>;
180
181    /// Derives one or more addresses corresponding to an output descriptor.
182    /// Examples of output descriptors are:
183    /// pkh(&lt;pubkey&gt;)                                     P2PKH outputs for the given pubkey
184    /// wpkh(&lt;pubkey&gt;)                                    Native segwit P2PKH outputs for the given pubkey
185    /// sh(multi(&lt;n&gt;,&lt;pubkey&gt;,&lt;pubkey&gt;,...))              P2SH-multisig outputs for the given threshold and pubkeys
186    /// raw(&lt;hex script&gt;)                                 Outputs whose output script equals the specified hex-encoded bytes
187    /// tr(&lt;pubkey&gt;,multi_a(&lt;n&gt;,&lt;pubkey&gt;,&lt;pubkey&gt;,...))   P2TR-multisig outputs for the given threshold and pubkeys
188    /// In the above, &lt;pubkey&gt; either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one
189    /// or more path elements separated by "/", where "h" represents a hardened child key.
190    /// For more information on output descriptors, see the documentation in the doc/descriptors.md file.
191    async fn derive_addresses(
192        &self,
193        descriptor: String,
194        range: Option<serde_json::Value>,
195    ) -> Result<DeriveAddressesResponse, Self::Error>;
196
197    /// Update all segwit inputs in a PSBT with information from output descriptors, the UTXO set or the mempool.
198    /// Then, sign the inputs we are able to with information from the output descriptors.
199    async fn descriptor_process_psbt(
200        &self,
201        psbt: String,
202        descriptors: Vec<serde_json::Value>,
203        sighashtype: Option<String>,
204        bip32derivs: Option<bool>,
205        finalize: Option<bool>,
206    ) -> Result<DescriptorProcessPsbtResponse, Self::Error>;
207
208    /// Immediately disconnects from the specified peer node.
209    /// Strictly one out of 'address' and 'nodeid' can be provided to identify the node.
210    /// To disconnect by nodeid, either set 'address' to the empty string, or call using the named 'nodeid' argument only.
211    async fn disconnect_node(
212        &self,
213        address: Option<bitcoin::Address>,
214        nodeid: Option<i64>,
215    ) -> Result<DisconnectNodeResponse, Self::Error>;
216
217    /// Write the serialized UTXO set to a file. This can be used in loadtxoutset afterwards if this snapshot height is supported in the chainparams as well.
218    /// Unless the "latest" type is requested, the node will roll back to the requested height and network activity will be suspended during this process. Because of this it is discouraged to interact with the node in any other way during the execution of this call to avoid inconsistent results and race conditions, particularly RPCs that interact with blockstorage.
219    /// This call may take several minutes. Make sure to use no RPC timeout (bitcoin-cli -rpcclienttimeout=0)
220    async fn dump_txout_set(
221        &self,
222        path: String,
223        r#type: Option<String>,
224        options: Option<serde_json::Value>,
225    ) -> Result<DumpTxoutSetResponse, Self::Error>;
226
227    /// Simply echo back the input arguments. This command is for testing.
228    /// It will return an internal bug report when arg9='trigger_internal_bug' is passed.
229    /// The difference between echo and echojson is that echojson has argument conversion enabled in the client-side table in bitcoin-cli and the GUI. There is no server-side difference.
230    async fn echo(
231        &self,
232        arg0: Option<String>,
233        arg1: Option<String>,
234        arg2: Option<String>,
235        arg3: Option<String>,
236        arg4: Option<String>,
237        arg5: Option<String>,
238        arg6: Option<String>,
239        arg7: Option<String>,
240        arg8: Option<String>,
241        arg9: Option<String>,
242    ) -> Result<EchoResponse, Self::Error>;
243
244    /// Echo back the input argument, passing it through a spawned process in a multiprocess build.
245    /// This command is for testing.
246    async fn echoipc(&self, arg: String) -> Result<EchoipcResponse, Self::Error>;
247
248    /// Simply echo back the input arguments. This command is for testing.
249    /// It will return an internal bug report when arg9='trigger_internal_bug' is passed.
250    /// The difference between echo and echojson is that echojson has argument conversion enabled in the client-side table in bitcoin-cli and the GUI. There is no server-side difference.
251    async fn echojson(
252        &self,
253        arg0: Option<String>,
254        arg1: Option<String>,
255        arg2: Option<String>,
256        arg3: Option<String>,
257        arg4: Option<String>,
258        arg5: Option<String>,
259        arg6: Option<String>,
260        arg7: Option<String>,
261        arg8: Option<String>,
262        arg9: Option<String>,
263    ) -> Result<EchojsonResponse, Self::Error>;
264
265    /// Encrypts the wallet with 'passphrase'. This is for first time encryption.
266    /// After this, any calls that interact with private keys such as sending or signing
267    /// will require the passphrase to be set prior to making these calls.
268    /// Use the walletpassphrase call for this, and then walletlock call.
269    /// If the wallet is already encrypted, use the walletpassphrasechange call.
270    /// ** IMPORTANT **
271    /// For security reasons, the encryption process will generate a new HD seed, resulting
272    /// in the creation of a fresh set of active descriptors. Therefore, it is crucial to
273    /// securely back up the newly generated wallet file using the backupwallet RPC.
274    async fn encrypt_wallet(
275        &self,
276        passphrase: String,
277    ) -> Result<EncryptWalletResponse, Self::Error>;
278
279    /// Returns a list of external signers from -signer.
280    async fn enumerate_signers(&self) -> Result<EnumerateSignersResponse, Self::Error>;
281
282    /// WARNING: This interface is unstable and may disappear or change!
283    /// WARNING: This is an advanced API call that is tightly coupled to the specific
284    /// implementation of fee estimation. The parameters it can be called with
285    /// and the results it returns will change if the internal implementation changes.
286    /// Estimates the approximate fee per kilobyte needed for a transaction to begin
287    /// confirmation within conf_target blocks if possible. Uses virtual transaction size as
288    /// defined in BIP 141 (witness data is discounted).
289    async fn estimate_raw_fee(
290        &self,
291        conf_target: i64,
292        threshold: Option<i64>,
293    ) -> Result<EstimateRawFeeResponse, Self::Error>;
294
295    /// Estimates the approximate fee per kilobyte needed for a transaction to begin
296    /// confirmation within conf_target blocks if possible and return the number of blocks
297    /// for which the estimate is valid. Uses virtual transaction size as defined
298    /// in BIP 141 (witness data is discounted).
299    async fn estimate_smart_fee(
300        &self,
301        conf_target: i64,
302        estimate_mode: Option<String>,
303    ) -> Result<EstimateSmartFeeResponse, Self::Error>;
304
305    /// Finalize the inputs of a PSBT. If the transaction is fully signed, it will produce a
306    /// network serialized transaction which can be broadcast with sendrawtransaction. Otherwise a PSBT will be
307    /// created which has the final_scriptSig and final_scriptwitness fields filled for inputs that are complete.
308    /// Implements the Finalizer and Extractor roles.
309    async fn finalize_psbt(
310        &self,
311        psbt: String,
312        extract: Option<bool>,
313    ) -> Result<FinalizePsbtResponse, Self::Error>;
314
315    /// If the transaction has no inputs, they will be automatically selected to meet its out value.
316    /// It will add at most one change output to the outputs.
317    /// No existing outputs will be modified unless "subtractFeeFromOutputs" is specified.
318    /// Note that inputs which were signed may need to be resigned after completion since in/outputs have been added.
319    /// The inputs added will not be signed, use signrawtransactionwithkey
320    /// or signrawtransactionwithwallet for that.
321    /// All existing inputs must either have their previous output transaction be in the wallet
322    /// or be in the UTXO set. Solving data must be provided for non-wallet inputs.
323    /// Note that all inputs selected must be of standard form and P2SH scripts must be
324    /// in the wallet using importdescriptors (to calculate fees).
325    /// You can see whether this is the case by checking the "solvable" field in the listunspent output.
326    /// Note that if specifying an exact fee rate, the resulting transaction may have a higher fee rate
327    /// if the transaction has unconfirmed inputs. This is because the wallet will attempt to make the
328    /// entire package have the given fee rate, not the resulting transaction.
329    async fn fund_raw_transaction(
330        &self,
331        hexstring: String,
332        options: Option<serde_json::Value>,
333        iswitness: Option<bool>,
334    ) -> Result<FundRawTransactionResponse, Self::Error>;
335
336    /// has been replaced by the -generate cli option. Refer to -help for more information.
337    async fn generate(&self) -> Result<(), Self::Error>;
338
339    /// Mine a set of ordered transactions to a specified address or descriptor and return the block hash.
340    async fn generate_block(
341        &self,
342        output: String,
343        transactions: Vec<serde_json::Value>,
344        submit: Option<bool>,
345    ) -> Result<GenerateBlockResponse, Self::Error>;
346
347    /// Mine to a specified address and return the block hashes.
348    async fn generate_to_address(
349        &self,
350        nblocks: i64,
351        address: bitcoin::Address,
352        maxtries: Option<i64>,
353    ) -> Result<GenerateToAddressResponse, Self::Error>;
354
355    /// Mine to a specified descriptor and return the block hashes.
356    async fn generate_to_descriptor(
357        &self,
358        num_blocks: i64,
359        descriptor: String,
360        maxtries: Option<i64>,
361    ) -> Result<GenerateToDescriptorResponse, Self::Error>;
362
363    /// Returns information about the given added node, or all added nodes
364    /// (note that onetry addnodes are not listed here)
365    async fn get_added_node_info(
366        &self,
367        node: Option<String>,
368    ) -> Result<GetAddedNodeInfoResponse, Self::Error>;
369
370    /// Returns the list of addresses assigned the specified label.
371    async fn get_addresses_by_label(
372        &self,
373        label: String,
374    ) -> Result<GetAddressesByLabelResponse, Self::Error>;
375
376    /// Return information about the given bitcoin address.
377    /// Some of the information will only be present if the address is in the active wallet.
378    async fn get_address_info(
379        &self,
380        address: bitcoin::Address,
381    ) -> Result<GetAddressInfoResponse, Self::Error>;
382
383    /// Provides information about the node's address manager by returning the number of addresses in the `new` and `tried` tables and their sum for all networks.
384    async fn get_addrman_info(&self) -> Result<GetAddrmanInfoResponse, Self::Error>;
385
386    /// Returns the total available balance.
387    /// The available balance is what the wallet considers currently spendable, and is
388    /// thus affected by options which limit spendability such as -spendzeroconfchange.
389    async fn get_balance(
390        &self,
391        dummy: Option<String>,
392        minconf: Option<i64>,
393        include_watchonly: Option<bool>,
394        avoid_reuse: Option<bool>,
395    ) -> Result<GetBalanceResponse, Self::Error>;
396
397    /// Returns an object with all balances in BTC.
398    async fn get_balances(&self) -> Result<GetBalancesResponse, Self::Error>;
399
400    /// Returns the hash of the best (tip) block in the most-work fully-validated chain.
401    async fn get_best_block_hash(&self) -> Result<GetBestBlockHashResponse, Self::Error>;
402
403    /// If verbosity is 0, returns a string that is serialized, hex-encoded data for block 'hash'.
404    /// If verbosity is 1, returns an Object with information about block &lt;hash&gt;.
405    /// If verbosity is 2, returns an Object with information about block &lt;hash&gt; and information about each transaction.
406    /// If verbosity is 3, returns an Object with information about block &lt;hash&gt; and information about each transaction, including prevout information for inputs (only for unpruned blocks in the current best chain).
407    async fn get_block(
408        &self,
409        blockhash: bitcoin::BlockHash,
410        verbosity: Option<i64>,
411    ) -> Result<GetBlockResponse, Self::Error>;
412
413    /// Returns an object containing various state info regarding blockchain processing.
414    async fn get_blockchain_info(&self) -> Result<GetBlockchainInfoResponse, Self::Error>;
415
416    /// Returns the height of the most-work fully-validated chain.
417    /// The genesis block has height 0.
418    async fn get_block_count(&self) -> Result<GetBlockCountResponse, Self::Error>;
419
420    /// Retrieve a BIP 157 content filter for a particular block.
421    async fn get_block_filter(
422        &self,
423        blockhash: bitcoin::BlockHash,
424        filtertype: Option<String>,
425    ) -> Result<GetBlockFilterResponse, Self::Error>;
426
427    /// Attempt to fetch block from a given peer.
428    /// We must have the header for this block, e.g. using submitheader.
429    /// The block will not have any undo data which can limit the usage of the block data in a context where the undo data is needed.
430    /// Subsequent calls for the same block may cause the response from the previous peer to be ignored.
431    /// Peers generally ignore requests for a stale block that they never fully verified, or one that is more than a month old.
432    /// When a peer does not respond with a block, we will disconnect.
433    /// Note: The block could be re-pruned as soon as it is received.
434    /// Returns an empty JSON object if the request was successfully scheduled.
435    async fn get_block_from_peer(
436        &self,
437        blockhash: bitcoin::BlockHash,
438        peer_id: i64,
439    ) -> Result<GetBlockFromPeerResponse, Self::Error>;
440
441    /// Returns hash of block in best-block-chain at height provided.
442    async fn get_block_hash(&self, height: i64) -> Result<GetBlockHashResponse, Self::Error>;
443
444    /// If verbose is false, returns a string that is serialized, hex-encoded data for blockheader 'hash'.
445    /// If verbose is true, returns an Object with information about blockheader &lt;hash&gt;.
446    async fn get_block_header(
447        &self,
448        blockhash: bitcoin::BlockHash,
449        verbose: Option<bool>,
450    ) -> Result<GetBlockHeaderResponse, Self::Error>;
451
452    /// Compute per block statistics for a given window. All amounts are in satoshis.
453    /// It won't work for some heights with pruning.
454    async fn get_block_stats(
455        &self,
456        hash_or_height: i64,
457        stats: Option<Vec<serde_json::Value>>,
458    ) -> Result<GetBlockStatsResponse, Self::Error>;
459
460    /// If the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.
461    /// It returns data needed to construct a block to work on.
462    /// For full specification, see BIPs 22, 23, 9, and 145:
463    /// <https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki>
464    /// <https://github.com/bitcoin/bips/blob/master/bip-0023.mediawiki>
465    /// <https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes>
466    /// <https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki>
467    async fn get_block_template(
468        &self,
469        template_request: serde_json::Value,
470    ) -> Result<GetBlockTemplateResponse, Self::Error>;
471
472    /// Return information about chainstates.
473    async fn get_chain_states(&self) -> Result<GetChainStatesResponse, Self::Error>;
474
475    /// Return information about all known tips in the block tree, including the main chain as well as orphaned branches.
476    async fn get_chain_tips(&self) -> Result<GetChainTipsResponse, Self::Error>;
477
478    /// Compute statistics about the total number and rate of transactions in the chain.
479    async fn get_chain_tx_stats(
480        &self,
481        nblocks: Option<i64>,
482        blockhash: Option<bitcoin::BlockHash>,
483    ) -> Result<GetChainTxStatsResponse, Self::Error>;
484
485    /// Returns the number of connections to other nodes.
486    async fn get_connection_count(&self) -> Result<GetConnectionCountResponse, Self::Error>;
487
488    /// Returns an object containing various state info regarding deployments of consensus changes.
489    async fn get_deployment_info(
490        &self,
491        blockhash: Option<bitcoin::BlockHash>,
492    ) -> Result<GetDeploymentInfoResponse, Self::Error>;
493
494    /// Get spend and receive activity associated with a set of descriptors for a set of blocks. This command pairs well with the `relevant_blocks` output of `scanblocks()`.
495    /// This call may take several minutes. If you encounter timeouts, try specifying no RPC timeout (bitcoin-cli -rpcclienttimeout=0)
496    async fn get_descriptor_activity(
497        &self,
498        blockhashes: Vec<serde_json::Value>,
499        scanobjects: Vec<serde_json::Value>,
500        include_mempool: Option<bool>,
501    ) -> Result<GetDescriptorActivityResponse, Self::Error>;
502
503    /// Analyses a descriptor.
504    async fn get_descriptor_info(
505        &self,
506        descriptor: String,
507    ) -> Result<GetDescriptorInfoResponse, Self::Error>;
508
509    /// Returns the proof-of-work difficulty as a multiple of the minimum difficulty.
510    async fn get_difficulty(&self) -> Result<GetDifficultyResponse, Self::Error>;
511
512    /// List all BIP 32 HD keys in the wallet and which descriptors use them.
513    async fn get_hd_keys(
514        &self,
515        options: Option<serde_json::Value>,
516    ) -> Result<GetHdKeysResponse, Self::Error>;
517
518    /// Returns the status of one or all available indices currently running in the node.
519    async fn get_index_info(
520        &self,
521        index_name: Option<String>,
522    ) -> Result<GetIndexInfoResponse, Self::Error>;
523
524    /// Returns an object containing information about memory usage.
525    async fn get_memory_info(
526        &self,
527        mode: Option<String>,
528    ) -> Result<GetMemoryInfoResponse, Self::Error>;
529
530    /// If txid is in the mempool, returns all in-mempool ancestors.
531    async fn get_mempool_ancestors(
532        &self,
533        txid: bitcoin::Txid,
534        verbose: Option<bool>,
535    ) -> Result<GetMempoolAncestorsResponse, Self::Error>;
536
537    /// Returns mempool data for given cluster
538    async fn get_mempool_cluster(
539        &self,
540        txid: bitcoin::Txid,
541    ) -> Result<GetMempoolClusterResponse, Self::Error>;
542
543    /// If txid is in the mempool, returns all in-mempool descendants.
544    async fn get_mempool_descendants(
545        &self,
546        txid: bitcoin::Txid,
547        verbose: Option<bool>,
548    ) -> Result<GetMempoolDescendantsResponse, Self::Error>;
549
550    /// Returns mempool data for given transaction
551    async fn get_mempool_entry(
552        &self,
553        txid: bitcoin::Txid,
554    ) -> Result<GetMempoolEntryResponse, Self::Error>;
555
556    /// Returns the feerate diagram for the whole mempool.
557    async fn get_mempool_fee_rate_diagram(
558        &self,
559    ) -> Result<GetMempoolFeeRateDiagramResponse, Self::Error>;
560
561    /// Returns details on the active state of the TX memory pool.
562    async fn get_mempool_info(&self) -> Result<GetMempoolInfoResponse, Self::Error>;
563
564    /// Returns a json object containing mining-related information.
565    async fn get_mining_info(&self) -> Result<GetMiningInfoResponse, Self::Error>;
566
567    /// Returns information about network traffic, including bytes in, bytes out,
568    /// and current system time.
569    async fn get_net_totals(&self) -> Result<GetNetTotalsResponse, Self::Error>;
570
571    /// Returns the estimated network hashes per second based on the last n blocks.
572    /// Pass in \[blocks\] to override # of blocks, -1 specifies since last difficulty change.
573    /// Pass in \[height\] to estimate the network speed at the time when a certain block was found.
574    async fn get_network_hashps(
575        &self,
576        nblocks: Option<i64>,
577        height: Option<i64>,
578    ) -> Result<GetNetworkHashpsResponse, Self::Error>;
579
580    /// Returns an object containing various state info regarding P2P networking.
581    async fn get_network_info(&self) -> Result<GetNetworkInfoResponse, Self::Error>;
582
583    /// Returns a new Bitcoin address for receiving payments.
584    /// If 'label' is specified, it is added to the address book
585    /// so payments received with the address will be associated with 'label'.
586    async fn get_new_address(
587        &self,
588        label: Option<String>,
589        address_type: Option<String>,
590    ) -> Result<GetNewAddressResponse, Self::Error>;
591
592    /// Return known addresses, after filtering for quality and recency.
593    /// These can potentially be used to find new peers in the network.
594    /// The total number of addresses known to the node may be higher.
595    async fn get_node_addresses(
596        &self,
597        count: Option<i64>,
598        network: Option<String>,
599    ) -> Result<GetNodeAddressesResponse, Self::Error>;
600
601    /// Shows transactions in the tx orphanage.
602    /// EXPERIMENTAL warning: this call may be changed in future releases.
603    async fn get_orphan_txs(
604        &self,
605        verbosity: Option<i64>,
606    ) -> Result<GetOrphanTxsResponse, Self::Error>;
607
608    /// Returns data about each connected network peer as a json array of objects.
609    async fn get_peer_info(&self) -> Result<GetPeerInfoResponse, Self::Error>;
610
611    /// Returns a map of all user-created (see prioritisetransaction) fee deltas by txid, and whether the tx is present in mempool.
612    async fn get_prioritised_transactions(
613        &self,
614    ) -> Result<GetPrioritisedTransactionsResponse, Self::Error>;
615
616    /// EXPERIMENTAL warning: this call may be changed in future releases.
617    /// Returns information on all address manager entries for the new and tried tables.
618    async fn get_raw_addrman(&self) -> Result<GetRawAddrmanResponse, Self::Error>;
619
620    /// Returns a new Bitcoin address, for receiving change.
621    /// This is for use with raw transactions, NOT normal use.
622    async fn get_raw_change_address(
623        &self,
624        address_type: Option<String>,
625    ) -> Result<GetRawChangeAddressResponse, Self::Error>;
626
627    /// Returns all transaction ids in memory pool as a json array of string transaction ids.
628    /// Hint: use getmempoolentry to fetch a specific transaction from the mempool.
629    async fn get_raw_mempool(
630        &self,
631        verbose: Option<bool>,
632        mempool_sequence: Option<bool>,
633    ) -> Result<GetRawMempoolResponse, Self::Error>;
634
635    /// By default, this call only returns a transaction if it is in the mempool. If -txindex is enabled
636    /// and no blockhash argument is passed, it will return the transaction if it is in the mempool or any block.
637    /// If a blockhash argument is passed, it will return the transaction if
638    /// the specified block is available and the transaction is in that block.
639    /// Hint: Use gettransaction for wallet transactions.
640    /// If verbosity is 0 or omitted, returns the serialized transaction as a hex-encoded string.
641    /// If verbosity is 1, returns a JSON Object with information about the transaction.
642    /// If verbosity is 2, returns a JSON Object with information about the transaction, including fee and prevout information.
643    async fn get_raw_transaction(
644        &self,
645        txid: bitcoin::Txid,
646        verbosity: Option<i64>,
647        blockhash: Option<bitcoin::BlockHash>,
648    ) -> Result<GetRawTransactionResponse, Self::Error>;
649
650    /// Returns the total amount received by the given address in transactions with at least minconf confirmations.
651    async fn get_received_by_address(
652        &self,
653        address: bitcoin::Address,
654        minconf: Option<i64>,
655        include_immature_coinbase: Option<bool>,
656    ) -> Result<GetReceivedByAddressResponse, Self::Error>;
657
658    /// Returns the total amount received by addresses with &lt;label&gt; in transactions with at least \[minconf\] confirmations.
659    async fn get_received_by_label(
660        &self,
661        label: String,
662        minconf: Option<i64>,
663        include_immature_coinbase: Option<bool>,
664    ) -> Result<GetReceivedByLabelResponse, Self::Error>;
665
666    /// Returns details of the RPC server.
667    async fn get_rpc_info(&self) -> Result<GetRpcInfoResponse, Self::Error>;
668
669    /// Get detailed information about in-wallet transaction &lt;txid&gt;
670    async fn get_transaction(
671        &self,
672        txid: bitcoin::Txid,
673        include_watchonly: Option<bool>,
674        verbose: Option<bool>,
675    ) -> Result<GetTransactionResponse, Self::Error>;
676
677    /// Returns details about an unspent transaction output.
678    async fn get_txout(
679        &self,
680        txid: bitcoin::Txid,
681        n: i64,
682        include_mempool: Option<bool>,
683    ) -> Result<GetTxoutResponse, Self::Error>;
684
685    /// Returns a hex-encoded proof that "txid" was included in a block.
686    /// NOTE: By default this function only works sometimes. This is when there is an
687    /// unspent output in the utxo for this transaction. To make it always work,
688    /// you need to maintain a transaction index, using the -txindex command line option or
689    /// specify the block in which the transaction is included manually (by blockhash).
690    async fn get_txout_proof(
691        &self,
692        txids: Vec<serde_json::Value>,
693        blockhash: Option<bitcoin::BlockHash>,
694    ) -> Result<GetTxoutProofResponse, Self::Error>;
695
696    /// Returns statistics about the unspent transaction output set.
697    /// Note this call may take some time if you are not using coinstatsindex.
698    async fn get_txout_set_info(
699        &self,
700        hash_type: Option<String>,
701        hash_or_height: Option<i64>,
702        use_index: Option<bool>,
703    ) -> Result<GetTxoutSetInfoResponse, Self::Error>;
704
705    /// Scans the mempool to find transactions spending any of the given outputs
706    async fn get_tx_spending_prevout(
707        &self,
708        outputs: Vec<serde_json::Value>,
709    ) -> Result<GetTxSpendingPrevoutResponse, Self::Error>;
710
711    /// Returns an object containing various wallet state info.
712    async fn get_wallet_info(&self) -> Result<GetWalletInfoResponse, Self::Error>;
713
714    /// List all commands, or get help for a specified command.
715    async fn help(&self, command: Option<String>) -> Result<HelpResponse, Self::Error>;
716
717    /// Import descriptors. This will trigger a rescan of the blockchain based on the earliest timestamp of all descriptors being imported. Requires a new wallet backup.
718    /// When importing descriptors with multipath key expressions, if the multipath specifier contains exactly two elements, the descriptor produced from the second element will be imported as an internal descriptor.
719    /// Note: This call can take over an hour to complete if using an early timestamp; during that time, other rpc calls
720    /// may report that the imported keys, addresses or scripts exist but related transactions are still missing.
721    /// The rescan is significantly faster if block filters are available (using startup option "-blockfilterindex=1").
722    async fn import_descriptors(
723        &self,
724        requests: Vec<serde_json::Value>,
725    ) -> Result<ImportDescriptorsResponse, Self::Error>;
726
727    /// Import a mempool.dat file and attempt to add its contents to the mempool.
728    /// Warning: Importing untrusted files is dangerous, especially if metadata from the file is taken over.
729    async fn import_mempool(
730        &self,
731        filepath: String,
732        options: Option<serde_json::Value>,
733    ) -> Result<ImportMempoolResponse, Self::Error>;
734
735    /// Imports funds without rescan. Corresponding address or script must previously be included in wallet. Aimed towards pruned wallets. The end-user is responsible to import additional transactions that subsequently spend the imported outputs or rescan after the point in the blockchain the transaction is included.
736    async fn import_pruned_funds(
737        &self,
738        rawtransaction: String,
739        txoutproof: String,
740    ) -> Result<ImportPrunedFundsResponse, Self::Error>;
741
742    /// Permanently marks a block as invalid, as if it violated a consensus rule.
743    async fn invalidate_block(
744        &self,
745        blockhash: bitcoin::BlockHash,
746    ) -> Result<InvalidateBlockResponse, Self::Error>;
747
748    /// Joins multiple distinct PSBTs with different inputs and outputs into one PSBT with inputs and outputs from all of the PSBTs
749    /// No input in any of the PSBTs can be in more than one of the PSBTs.
750    async fn join_psbts(
751        &self,
752        txs: Vec<serde_json::Value>,
753    ) -> Result<JoinPsbtsResponse, Self::Error>;
754
755    /// Refills each descriptor keypool in the wallet up to the specified number of new keys.
756    /// By default, descriptor wallets have 4 active ranged descriptors ("legacy", "p2sh-segwit", "bech32", "bech32m"), each with 1000 entries.
757    /// Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.
758    async fn keypool_refill(
759        &self,
760        newsize: Option<i64>,
761    ) -> Result<KeypoolRefillResponse, Self::Error>;
762
763    /// Lists groups of addresses which have had their common ownership
764    /// made public by common use as inputs or as the resulting change
765    /// in past transactions
766    async fn list_address_groupings(&self) -> Result<ListAddressGroupingsResponse, Self::Error>;
767
768    /// List all manually banned IPs/Subnets.
769    async fn list_banned(&self) -> Result<ListBannedResponse, Self::Error>;
770
771    /// List all descriptors present in a wallet.
772    async fn list_descriptors(
773        &self,
774        private: Option<bool>,
775    ) -> Result<ListDescriptorsResponse, Self::Error>;
776
777    /// Returns the list of all labels, or labels that are assigned to addresses with a specific purpose.
778    async fn list_labels(&self, purpose: Option<String>)
779        -> Result<ListLabelsResponse, Self::Error>;
780
781    /// Returns list of temporarily unspendable outputs.
782    /// See the lockunspent call to lock and unlock transactions for spending.
783    async fn list_lock_unspent(&self) -> Result<ListLockUnspentResponse, Self::Error>;
784
785    /// List balances by receiving address.
786    async fn list_received_by_address(
787        &self,
788        minconf: Option<i64>,
789        include_empty: Option<bool>,
790        include_watchonly: Option<bool>,
791        address_filter: Option<String>,
792        include_immature_coinbase: Option<bool>,
793    ) -> Result<ListReceivedByAddressResponse, Self::Error>;
794
795    /// List received transactions by label.
796    async fn list_received_by_label(
797        &self,
798        minconf: Option<i64>,
799        include_empty: Option<bool>,
800        include_watchonly: Option<bool>,
801        include_immature_coinbase: Option<bool>,
802    ) -> Result<ListReceivedByLabelResponse, Self::Error>;
803
804    /// Get all transactions in blocks since block \[blockhash\], or all transactions if omitted.
805    /// If "blockhash" is no longer a part of the main chain, transactions from the fork point onward are included.
806    /// Additionally, if include_removed is set, transactions affecting the wallet which were removed are returned in the "removed" array.
807    async fn list_since_block(
808        &self,
809        blockhash: Option<bitcoin::BlockHash>,
810        target_confirmations: Option<i64>,
811        include_watchonly: Option<bool>,
812        include_removed: Option<bool>,
813        include_change: Option<bool>,
814        label: Option<String>,
815    ) -> Result<ListSinceBlockResponse, Self::Error>;
816
817    /// If a label name is provided, this will return only incoming transactions paying to addresses with the specified label.
818    /// Returns up to 'count' most recent transactions ordered from oldest to newest while skipping the first number of
819    /// transactions specified in the 'skip' argument. A transaction can have multiple entries in this RPC response.
820    /// For instance, a wallet transaction that pays three addresses — one wallet-owned and two external — will produce
821    /// four entries. The payment to the wallet-owned address appears both as a send entry and as a receive entry.
822    /// As a result, the RPC response will contain one entry in the receive category and three entries in the send category.
823    async fn list_transactions(
824        &self,
825        label: Option<String>,
826        count: Option<i64>,
827        skip: Option<i64>,
828        include_watchonly: Option<bool>,
829    ) -> Result<ListTransactionsResponse, Self::Error>;
830
831    /// Returns array of unspent transaction outputs
832    /// with between minconf and maxconf (inclusive) confirmations.
833    /// Optionally filter to only include txouts paid to specified addresses.
834    async fn list_unspent(
835        &self,
836        minconf: Option<i64>,
837        maxconf: Option<i64>,
838        addresses: Option<Vec<serde_json::Value>>,
839        include_unsafe: Option<bool>,
840        query_options: Option<serde_json::Value>,
841    ) -> Result<ListUnspentResponse, Self::Error>;
842
843    /// Returns a list of wallets in the wallet directory.
844    async fn list_wallet_dir(&self) -> Result<ListWalletDirResponse, Self::Error>;
845
846    /// Returns a list of currently loaded wallets.
847    /// For full information on the wallet, use "getwalletinfo"
848    async fn list_wallets(&self) -> Result<ListWalletsResponse, Self::Error>;
849
850    /// Load the serialized UTXO set from a file.
851    /// Once this snapshot is loaded, its contents will be deserialized into a second chainstate data structure, which is then used to sync to the network's tip. Meanwhile, the original chainstate will complete the initial block download process in the background, eventually validating up to the block that the snapshot is based upon.
852    /// The result is a usable bitcoind instance that is current with the network tip in a matter of minutes rather than hours. UTXO snapshot are typically obtained from third-party sources (HTTP, torrent, etc.) which is reasonable since their contents are always checked by hash.
853    /// You can find more information on this process in the `assumeutxo` design document (<https://github.com/bitcoin/bitcoin/blob/master/doc/design/assumeutxo.md>).
854    async fn load_txout_set(&self, path: String) -> Result<LoadTxoutSetResponse, Self::Error>;
855
856    /// Loads a wallet from a wallet file or directory.
857    /// Note that all wallet command-line options used when starting bitcoind will be
858    /// applied to the new wallet.
859    async fn load_wallet(
860        &self,
861        filename: String,
862        load_on_startup: Option<bool>,
863    ) -> Result<LoadWalletResponse, Self::Error>;
864
865    /// Updates list of temporarily unspendable outputs.
866    /// Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs.
867    /// If no transaction outputs are specified when unlocking then all current locked transaction outputs are unlocked.
868    /// A locked transaction output will not be chosen by automatic coin selection, when spending bitcoins.
869    /// Manually selected coins are automatically unlocked.
870    /// Locks are stored in memory only, unless persistent=true, in which case they will be written to the
871    /// wallet database and loaded on node start. Unwritten (persistent=false) locks are always cleared
872    /// (by virtue of process exit) when a node stops or fails. Unlocking will clear both persistent and not.
873    /// Also see the listunspent call
874    async fn lock_unspent(
875        &self,
876        unlock: bool,
877        transactions: Option<Vec<serde_json::Value>>,
878        persistent: Option<bool>,
879    ) -> Result<LockUnspentResponse, Self::Error>;
880
881    /// Gets and sets the logging configuration.
882    /// When called without an argument, returns the list of categories with status that are currently being debug logged or not.
883    /// When called with arguments, adds or removes categories from debug logging and return the lists above.
884    /// The arguments are evaluated in order "include", "exclude".
885    /// If an item is both included and excluded, it will thus end up being excluded.
886    /// The valid logging categories are: addrman, bench, blockstorage, cmpctblock, coindb, estimatefee, http, i2p, ipc, kernel, leveldb, libevent, mempool, mempoolrej, net, privatebroadcast, proxy, prune, qt, rand, reindex, rpc, scan, selectcoins, tor, txpackages, txreconciliation, validation, walletdb, zmq
887    /// In addition, the following are available as category names with special meanings:
888    /// - "all",  "1" : represent all logging categories.
889    async fn logging(
890        &self,
891        include: Option<Vec<serde_json::Value>>,
892        exclude: Option<Vec<serde_json::Value>>,
893    ) -> Result<LoggingResponse, Self::Error>;
894
895    /// Migrate the wallet to a descriptor wallet.
896    /// A new wallet backup will need to be made.
897    /// The migration process will create a backup of the wallet before migrating. This backup
898    /// file will be named &lt;wallet name&gt;-&lt;timestamp&gt;.legacy.bak and can be found in the directory
899    /// for this wallet. In the event of an incorrect migration, the backup can be restored using restorewallet.
900    /// Encrypted wallets must have the passphrase provided as an argument to this call.
901    /// This RPC may take a long time to complete. Increasing the RPC client timeout is recommended.
902    async fn migrate_wallet(
903        &self,
904        wallet_name: Option<String>,
905        passphrase: Option<String>,
906    ) -> Result<MigrateWalletResponse, Self::Error>;
907
908    /// Bump the scheduler into the future (-regtest only)
909    async fn mock_scheduler(&self, delta_time: i64) -> Result<MockSchedulerResponse, Self::Error>;
910
911    /// Requests that a ping be sent to all other nodes, to measure ping time.
912    /// Results are provided in getpeerinfo.
913    /// Ping command is handled in queue with all other commands, so it measures processing backlog, not just network ping.
914    async fn ping(&self) -> Result<PingResponse, Self::Error>;
915
916    /// Treats a block as if it were received before others with the same work.
917    /// A later preciousblock call can override the effect of an earlier one.
918    /// The effects of preciousblock are not retained across restarts.
919    async fn precious_block(
920        &self,
921        blockhash: bitcoin::BlockHash,
922    ) -> Result<PreciousBlockResponse, Self::Error>;
923
924    /// Accepts the transaction into mined blocks at a higher (or lower) priority
925    async fn prioritise_transaction(
926        &self,
927        txid: bitcoin::Txid,
928        dummy: Option<i64>,
929        fee_delta: i64,
930    ) -> Result<PrioritiseTransactionResponse, Self::Error>;
931
932    /// Attempts to delete block and undo data up to a specified height or timestamp, if eligible for pruning.
933    /// Requires `-prune` to be enabled at startup. While pruned data may be re-fetched in some cases (e.g., via `getblockfrompeer`), local deletion is irreversible.
934    async fn prune_blockchain(&self, height: i64) -> Result<PruneBlockchainResponse, Self::Error>;
935
936    /// Bumps the fee of a transaction T, replacing it with a new transaction B.
937    /// Returns a PSBT instead of creating and signing a new transaction.
938    /// A transaction with the given txid must be in the wallet.
939    /// The command will pay the additional fee by reducing change outputs or adding inputs when necessary.
940    /// It may add a new change output if one does not already exist.
941    /// All inputs in the original transaction will be included in the replacement transaction.
942    /// The command will fail if the wallet or mempool contains a transaction that spends one of T's outputs.
943    /// By default, the new fee will be calculated automatically using the estimatesmartfee RPC.
944    /// The user can specify a confirmation target for estimatesmartfee.
945    /// Alternatively, the user can specify a fee rate in sat/vB for the new transaction.
946    /// At a minimum, the new fee rate must be high enough to pay an additional new relay fee (incrementalfee
947    /// returned by getnetworkinfo) to enter the node's mempool.
948    /// * WARNING: before version 0.21, fee_rate was in BTC/kvB. As of 0.21, fee_rate is in sat/vB. *
949    async fn psbt_bump_fee(
950        &self,
951        txid: bitcoin::Txid,
952        options: Option<serde_json::Value>,
953    ) -> Result<PsbtBumpFeeResponse, Self::Error>;
954
955    /// Removes invalidity status of a block, its ancestors and its descendants, reconsider them for activation.
956    /// This can be used to undo the effects of invalidateblock.
957    async fn reconsider_block(
958        &self,
959        blockhash: bitcoin::BlockHash,
960    ) -> Result<ReconsiderBlockResponse, Self::Error>;
961
962    /// Deletes the specified transaction from the wallet. Meant for use with pruned wallets and as a companion to importprunedfunds. This will affect wallet balances.
963    async fn remove_pruned_funds(
964        &self,
965        txid: bitcoin::Txid,
966    ) -> Result<RemovePrunedFundsResponse, Self::Error>;
967
968    /// Rescan the local blockchain for wallet related transactions.
969    /// Note: Use "getwalletinfo" to query the scanning progress.
970    /// The rescan is significantly faster if block filters are available
971    /// (using startup option "-blockfilterindex=1").
972    async fn rescan_blockchain(
973        &self,
974        start_height: Option<i64>,
975        stop_height: Option<i64>,
976    ) -> Result<RescanBlockchainResponse, Self::Error>;
977
978    /// Restores and loads a wallet from backup.
979    /// The rescan is significantly faster if block filters are available
980    /// (using startup option "-blockfilterindex=1").
981    async fn restore_wallet(
982        &self,
983        wallet_name: String,
984        backup_file: String,
985        load_on_startup: Option<bool>,
986    ) -> Result<RestoreWalletResponse, Self::Error>;
987
988    /// Dumps the mempool to disk. It will fail until the previous dump is fully loaded.
989    async fn save_mempool(&self) -> Result<SaveMempoolResponse, Self::Error>;
990
991    /// Return relevant blockhashes for given descriptors (requires blockfilterindex).
992    /// This call may take several minutes. Make sure to use no RPC timeout (bitcoin-cli -rpcclienttimeout=0)
993    async fn scan_blocks(
994        &self,
995        action: String,
996        scanobjects: Option<Vec<serde_json::Value>>,
997        start_height: Option<i64>,
998        stop_height: Option<i64>,
999        filtertype: Option<String>,
1000        options: Option<serde_json::Value>,
1001    ) -> Result<ScanBlocksResponse, Self::Error>;
1002
1003    /// Scans the unspent transaction output set for entries that match certain output descriptors.
1004    /// Examples of output descriptors are:
1005    /// addr(&lt;address&gt;)                      Outputs whose output script corresponds to the specified address (does not include P2PK)
1006    /// raw(&lt;hex script&gt;)                    Outputs whose output script equals the specified hex-encoded bytes
1007    /// combo(&lt;pubkey&gt;)                      P2PK, P2PKH, P2WPKH, and P2SH-P2WPKH outputs for the given pubkey
1008    /// pkh(&lt;pubkey&gt;)                        P2PKH outputs for the given pubkey
1009    /// sh(multi(&lt;n&gt;,&lt;pubkey&gt;,&lt;pubkey&gt;,...)) P2SH-multisig outputs for the given threshold and pubkeys
1010    /// tr(&lt;pubkey&gt;)                         P2TR
1011    /// tr(&lt;pubkey&gt;,{pk(&lt;pubkey&gt;)})          P2TR with single fallback pubkey in tapscript
1012    /// rawtr(&lt;pubkey&gt;)                      P2TR with the specified key as output key rather than inner
1013    /// wsh(and_v(v:pk(&lt;pubkey&gt;),after(2)))  P2WSH miniscript with mandatory pubkey and a timelock
1014    /// In the above, &lt;pubkey&gt; either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one
1015    /// or more path elements separated by "/", and optionally ending in "/*" (unhardened), or "/*'" or "/*h" (hardened) to specify all
1016    /// unhardened or hardened child keys.
1017    /// In the latter case, a range needs to be specified by below if different from 1000.
1018    /// For more information on output descriptors, see the documentation in the doc/descriptors.md file.
1019    async fn scan_txout_set(
1020        &self,
1021        action: String,
1022        scanobjects: Option<Vec<serde_json::Value>>,
1023    ) -> Result<ScanTxoutSetResponse, Self::Error>;
1024
1025    /// Return RPC command JSON Schema descriptions.
1026    async fn schema(&self) -> Result<SchemaResponse, Self::Error>;
1027
1028    /// EXPERIMENTAL warning: this call may be changed in future releases.
1029    /// Send a transaction.
1030    async fn send(
1031        &self,
1032        outputs: Vec<serde_json::Value>,
1033        conf_target: Option<i64>,
1034        estimate_mode: Option<String>,
1035        fee_rate: Option<serde_json::Value>,
1036        options: Option<serde_json::Value>,
1037        version: Option<i64>,
1038    ) -> Result<SendResponse, Self::Error>;
1039
1040    /// EXPERIMENTAL warning: this call may be changed in future releases.
1041    /// Spend the value of all (or specific) confirmed UTXOs and unconfirmed change in the wallet to one or more recipients.
1042    /// Unconfirmed inbound UTXOs and locked UTXOs will not be spent. Sendall will respect the avoid_reuse wallet flag.
1043    /// If your wallet contains many small inputs, either because it received tiny payments or as a result of accumulating change, consider using `send_max` to exclude inputs that are worth less than the fees needed to spend them.
1044    async fn send_all(
1045        &self,
1046        recipients: Vec<serde_json::Value>,
1047        conf_target: Option<i64>,
1048        estimate_mode: Option<String>,
1049        fee_rate: Option<serde_json::Value>,
1050        options: Option<serde_json::Value>,
1051    ) -> Result<SendAllResponse, Self::Error>;
1052
1053    /// Send multiple times. Amounts are double-precision floating point numbers.
1054    /// Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.
1055    async fn send_many(
1056        &self,
1057        dummy: Option<String>,
1058        amounts: serde_json::Value,
1059        minconf: Option<i64>,
1060        comment: Option<String>,
1061        subtractfeefrom: Option<Vec<serde_json::Value>>,
1062        replaceable: Option<bool>,
1063        conf_target: Option<i64>,
1064        estimate_mode: Option<String>,
1065        fee_rate: Option<serde_json::Value>,
1066        verbose: Option<bool>,
1067    ) -> Result<SendManyResponse, Self::Error>;
1068
1069    /// Send a p2p message to a peer specified by id.
1070    /// The message type and body must be provided, the message header will be generated.
1071    /// This RPC is for testing only.
1072    async fn send_msg_to_peer(
1073        &self,
1074        peer_id: i64,
1075        msg_type: String,
1076        msg: String,
1077    ) -> Result<SendMsgToPeerResponse, Self::Error>;
1078
1079    /// Submit a raw transaction (serialized, hex-encoded) to the network.
1080    /// If -privatebroadcast is disabled, then the transaction will be put into the
1081    /// local mempool of the node and will be sent unconditionally to all currently
1082    /// connected peers, so using sendrawtransaction for manual rebroadcast will degrade
1083    /// privacy by leaking the transaction's origin, as nodes will normally not
1084    /// rebroadcast non-wallet transactions already in their mempool.
1085    /// If -privatebroadcast is enabled, then the transaction will be sent only via
1086    /// dedicated, short-lived connections to Tor or I2P peers or IPv4/IPv6 peers
1087    /// via the Tor network. This conceals the transaction's origin. The transaction
1088    /// will only enter the local mempool when it is received back from the network.
1089    /// A specific exception, RPC_TRANSACTION_ALREADY_IN_UTXO_SET, may throw if the transaction cannot be added to the mempool.
1090    /// Related RPCs: createrawtransaction, signrawtransactionwithkey
1091    async fn send_raw_transaction(
1092        &self,
1093        hexstring: String,
1094        maxfeerate: Option<serde_json::Value>,
1095        maxburnamount: Option<serde_json::Value>,
1096    ) -> Result<SendRawTransactionResponse, Self::Error>;
1097
1098    /// Send an amount to a given address.
1099    /// Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.
1100    async fn send_to_address(
1101        &self,
1102        address: bitcoin::Address,
1103        amount: serde_json::Value,
1104        comment: Option<String>,
1105        comment_to: Option<String>,
1106        subtractfeefromamount: Option<bool>,
1107        replaceable: Option<bool>,
1108        conf_target: Option<i64>,
1109        estimate_mode: Option<String>,
1110        avoid_reuse: Option<bool>,
1111        fee_rate: Option<serde_json::Value>,
1112        verbose: Option<bool>,
1113    ) -> Result<SendToAddressResponse, Self::Error>;
1114
1115    /// Attempts to add or remove an IP/Subnet from the banned list.
1116    async fn set_ban(
1117        &self,
1118        subnet: String,
1119        command: String,
1120        bantime: Option<i64>,
1121        absolute: Option<bool>,
1122    ) -> Result<SetBanResponse, Self::Error>;
1123
1124    /// Sets the label associated with the given address.
1125    async fn set_label(
1126        &self,
1127        address: bitcoin::Address,
1128        label: String,
1129    ) -> Result<SetLabelResponse, Self::Error>;
1130
1131    /// Set the local time to given timestamp (-regtest only)
1132    async fn set_mock_time(&self, timestamp: i64) -> Result<SetMockTimeResponse, Self::Error>;
1133
1134    /// Disable/enable all p2p network activity.
1135    async fn set_network_active(
1136        &self,
1137        state: bool,
1138    ) -> Result<SetNetworkActiveResponse, Self::Error>;
1139
1140    /// (DEPRECATED) Set the transaction fee rate in BTC/kvB for this wallet. Overrides the global -paytxfee command line parameter.
1141    /// Can be deactivated by passing 0 as the fee. In that case automatic fee selection will be used by default.
1142    async fn set_tx_fee(&self, amount: serde_json::Value) -> Result<SetTxFeeResponse, Self::Error>;
1143
1144    /// Change the state of the given wallet flag for a wallet.
1145    async fn set_wallet_flag(
1146        &self,
1147        flag: String,
1148        value: Option<bool>,
1149    ) -> Result<SetWalletFlagResponse, Self::Error>;
1150
1151    /// Sign a message with the private key of an address
1152    /// Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.
1153    async fn sign_message(
1154        &self,
1155        address: bitcoin::Address,
1156        message: String,
1157    ) -> Result<SignMessageResponse, Self::Error>;
1158
1159    /// Sign a message with the private key of an address
1160    async fn sign_message_with_priv_key(
1161        &self,
1162        privkey: String,
1163        message: String,
1164    ) -> Result<SignMessageWithPrivKeyResponse, Self::Error>;
1165
1166    /// Sign inputs for raw transaction (serialized, hex-encoded).
1167    /// The second argument is an array of base58-encoded private
1168    /// keys that will be the only keys used to sign the transaction.
1169    /// The third optional argument (may be null) is an array of previous transaction outputs that
1170    /// this transaction depends on but may not yet be in the block chain.
1171    async fn sign_raw_transaction_with_key(
1172        &self,
1173        hexstring: String,
1174        privkeys: Vec<serde_json::Value>,
1175        prevtxs: Option<Vec<serde_json::Value>>,
1176        sighashtype: Option<String>,
1177    ) -> Result<SignRawTransactionWithKeyResponse, Self::Error>;
1178
1179    /// Sign inputs for raw transaction (serialized, hex-encoded).
1180    /// The second optional argument (may be null) is an array of previous transaction outputs that
1181    /// this transaction depends on but may not yet be in the block chain.
1182    /// Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.
1183    async fn sign_raw_transaction_with_wallet(
1184        &self,
1185        hexstring: String,
1186        prevtxs: Option<Vec<serde_json::Value>>,
1187        sighashtype: Option<String>,
1188    ) -> Result<SignRawTransactionWithWalletResponse, Self::Error>;
1189
1190    /// Calculate the balance change resulting in the signing and broadcasting of the given transaction(s).
1191    async fn simulate_raw_transaction(
1192        &self,
1193        rawtxs: Option<Vec<serde_json::Value>>,
1194        options: Option<serde_json::Value>,
1195    ) -> Result<SimulateRawTransactionResponse, Self::Error>;
1196
1197    /// Request a graceful shutdown of Bitcoin Core.
1198    async fn stop(&self, wait: Option<i64>) -> Result<StopResponse, Self::Error>;
1199
1200    /// Attempts to submit new block to network.
1201    /// See <https://en.bitcoin.it/wiki/BIP_0022> for full specification.
1202    async fn submit_block(
1203        &self,
1204        hexdata: String,
1205        dummy: Option<String>,
1206    ) -> Result<SubmitBlockResponse, Self::Error>;
1207
1208    /// Decode the given hexdata as a header and submit it as a candidate chain tip if valid.
1209    /// Throws when the header is invalid.
1210    async fn submit_header(&self, hexdata: String) -> Result<SubmitHeaderResponse, Self::Error>;
1211
1212    /// Submit a package of raw transactions (serialized, hex-encoded) to local node.
1213    /// The package will be validated according to consensus and mempool policy rules. If any transaction passes, it will be accepted to mempool.
1214    /// This RPC is experimental and the interface may be unstable. Refer to doc/policy/packages.md for documentation on package policies.
1215    /// Warning: successful submission does not mean the transactions will propagate throughout the network.
1216    async fn submit_package(
1217        &self,
1218        package: Vec<serde_json::Value>,
1219        maxfeerate: Option<serde_json::Value>,
1220        maxburnamount: Option<serde_json::Value>,
1221    ) -> Result<SubmitPackageResponse, Self::Error>;
1222
1223    /// Waits for the validation interface queue to catch up on everything that was there when we entered this function.
1224    async fn sync_with_validation_interface_queue(
1225        &self,
1226    ) -> Result<SyncWithValidationInterfaceQueueResponse, Self::Error>;
1227
1228    /// Returns result of mempool acceptance tests indicating if raw transaction(s) (serialized, hex-encoded) would be accepted by mempool.
1229    /// If multiple transactions are passed in, parents must come before children and package policies apply: the transactions cannot conflict with any mempool transactions or each other.
1230    /// If one transaction fails, other transactions may not be fully validated (the 'allowed' key will be blank).
1231    /// The maximum number of transactions allowed is 25.
1232    /// This checks if transactions violate the consensus or policy rules.
1233    /// See sendrawtransaction call.
1234    async fn test_mempool_accept(
1235        &self,
1236        rawtxs: Vec<serde_json::Value>,
1237        maxfeerate: Option<serde_json::Value>,
1238    ) -> Result<TestMempoolAcceptResponse, Self::Error>;
1239
1240    /// Unloads the wallet referenced by the request endpoint or the wallet_name argument.
1241    /// If both are specified, they must be identical.
1242    async fn unload_wallet(
1243        &self,
1244        wallet_name: Option<String>,
1245        load_on_startup: Option<bool>,
1246    ) -> Result<UnloadWalletResponse, Self::Error>;
1247
1248    /// Returns the total uptime of the server.
1249    async fn uptime(&self) -> Result<UptimeResponse, Self::Error>;
1250
1251    /// Updates all segwit inputs and outputs in a PSBT with data from output descriptors, the UTXO set, txindex, or the mempool.
1252    async fn utxo_update_psbt(
1253        &self,
1254        psbt: String,
1255        descriptors: Option<Vec<serde_json::Value>>,
1256    ) -> Result<UtxoUpdatePsbtResponse, Self::Error>;
1257
1258    /// Return information about the given bitcoin address.
1259    async fn validate_address(
1260        &self,
1261        address: bitcoin::Address,
1262    ) -> Result<ValidateAddressResponse, Self::Error>;
1263
1264    /// Verifies blockchain database.
1265    async fn verify_chain(
1266        &self,
1267        checklevel: Option<i64>,
1268        nblocks: Option<i64>,
1269    ) -> Result<VerifyChainResponse, Self::Error>;
1270
1271    /// Verify a signed message.
1272    async fn verify_message(
1273        &self,
1274        address: bitcoin::Address,
1275        signature: String,
1276        message: String,
1277    ) -> Result<VerifyMessageResponse, Self::Error>;
1278
1279    /// Verifies that a proof points to a transaction in a block, returning the transaction it commits to
1280    /// and throwing an RPC error if the block is not in our best chain
1281    async fn verify_txout_proof(
1282        &self,
1283        proof: String,
1284    ) -> Result<VerifyTxoutProofResponse, Self::Error>;
1285
1286    /// Waits for a specific new block and returns useful info about it.
1287    /// Returns the current block on timeout or exit.
1288    /// Make sure to use no RPC timeout (bitcoin-cli -rpcclienttimeout=0)
1289    async fn wait_for_block(
1290        &self,
1291        blockhash: bitcoin::BlockHash,
1292        timeout: Option<i64>,
1293    ) -> Result<WaitForBlockResponse, Self::Error>;
1294
1295    /// Waits for (at least) block height and returns the height and hash
1296    /// of the current tip.
1297    /// Returns the current block on timeout or exit.
1298    /// Make sure to use no RPC timeout (bitcoin-cli -rpcclienttimeout=0)
1299    async fn wait_for_block_height(
1300        &self,
1301        height: i64,
1302        timeout: Option<i64>,
1303    ) -> Result<WaitForBlockHeightResponse, Self::Error>;
1304
1305    /// Waits for any new block and returns useful info about it.
1306    /// Returns the current block on timeout or exit.
1307    /// Make sure to use no RPC timeout (bitcoin-cli -rpcclienttimeout=0)
1308    async fn wait_for_new_block(
1309        &self,
1310        timeout: Option<i64>,
1311        current_tip: Option<String>,
1312    ) -> Result<WaitForNewBlockResponse, Self::Error>;
1313
1314    /// Creates and funds a transaction in the Partially Signed Transaction format.
1315    /// Implements the Creator and Updater roles.
1316    /// All existing inputs must either have their previous output transaction be in the wallet
1317    /// or be in the UTXO set. Solving data must be provided for non-wallet inputs.
1318    async fn wallet_create_funded_psbt(
1319        &self,
1320        inputs: Option<Vec<serde_json::Value>>,
1321        outputs: Vec<serde_json::Value>,
1322        locktime: Option<i64>,
1323        options: Option<serde_json::Value>,
1324        bip32derivs: Option<bool>,
1325        version: Option<i64>,
1326    ) -> Result<WalletCreateFundedPsbtResponse, Self::Error>;
1327
1328    /// Display address on an external signer for verification.
1329    async fn wallet_display_address(
1330        &self,
1331        address: bitcoin::Address,
1332    ) -> Result<WalletDisplayAddressResponse, Self::Error>;
1333
1334    /// Removes the wallet encryption key from memory, locking the wallet.
1335    /// After calling this method, you will need to call walletpassphrase again
1336    /// before being able to call any methods which require the wallet to be unlocked.
1337    async fn wallet_lock(&self) -> Result<WalletLockResponse, Self::Error>;
1338
1339    /// Stores the wallet decryption key in memory for 'timeout' seconds.
1340    /// This is needed prior to performing transactions related to private keys such as sending bitcoins
1341    /// Note:
1342    /// Issuing the walletpassphrase command while the wallet is already unlocked will set a new unlock
1343    /// time that overrides the old one.
1344    async fn wallet_passphrase(
1345        &self,
1346        passphrase: String,
1347        timeout: i64,
1348    ) -> Result<WalletPassphraseResponse, Self::Error>;
1349
1350    /// Changes the wallet passphrase from 'oldpassphrase' to 'newpassphrase'.
1351    async fn wallet_passphrase_change(
1352        &self,
1353        oldpassphrase: String,
1354        newpassphrase: String,
1355    ) -> Result<WalletPassphraseChangeResponse, Self::Error>;
1356
1357    /// Update a PSBT with input information from our wallet and then sign inputs
1358    /// that we can sign for.
1359    /// Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.
1360    async fn wallet_process_psbt(
1361        &self,
1362        psbt: String,
1363        sign: Option<bool>,
1364        sighashtype: Option<String>,
1365        bip32derivs: Option<bool>,
1366        finalize: Option<bool>,
1367    ) -> Result<WalletProcessPsbtResponse, Self::Error>;
1368}
1369
1370/// Helper to route calls to the node or wallet namespace automatically.
1371pub trait RpcDispatchExt: TransportTrait + TransportExt {
1372    /// Dispatch JSON-RPC methods by name.
1373    fn dispatch_json<R: DeserializeOwned>(
1374        &self,
1375        method: &str,
1376        params: &[serde_json::Value],
1377    ) -> impl Future<Output = Result<R, TransportError>> + Send {
1378        async move { self.call(method, params).await }
1379    }
1380}
1381
1382impl<T: TransportTrait + TransportExt + ?Sized> RpcDispatchExt for T {}
1383
1384// helper trait, so any TransportTrait gets a wallet_call by default
1385pub trait WalletTransportExt: TransportTrait + TransportExt {
1386    fn wallet_call<T: serde::Serialize + std::marker::Sync, R: serde::de::DeserializeOwned>(
1387        &self,
1388        method: &str,
1389        params: &[T],
1390    ) -> impl std::future::Future<Output = Result<R, crate::transport::TransportError>> + Send {
1391        async {
1392            // Convert params to Value before passing to call
1393            let value_params: Vec<serde_json::Value> =
1394                params.iter().map(|p| serde_json::to_value(p).unwrap()).collect();
1395            self.call(method, &value_params).await
1396        }
1397    }
1398}
1399
1400impl<T: TransportTrait + TransportExt + ?Sized> WalletTransportExt for T {}
1401
1402// Provide default implementation for any type that implements TransportTrait + TransportExt
1403#[async_trait]
1404impl<T: TransportTrait + TransportExt + Send + Sync> BitcoinClient for T {
1405    type Error = TransportError;
1406
1407    /// Mark in-wallet transaction &lt;txid&gt; as abandoned
1408    /// This will mark this transaction and all its in-wallet descendants as abandoned which will allow
1409    /// for their inputs to be respent.  It can be used to replace "stuck" or evicted transactions.
1410    /// It only works on transactions which are not included in a block and are not currently in the mempool.
1411    /// It has no effect on transactions which are already abandoned.
1412    async fn abandon_transaction(
1413        &self,
1414        txid: bitcoin::Txid,
1415    ) -> Result<AbandonTransactionResponse, Self::Error> {
1416        let mut rpc_params = vec![];
1417        rpc_params.push(serde_json::json!(txid));
1418        self.call::<AbandonTransactionResponse>("abandontransaction", &rpc_params).await
1419    }
1420
1421    /// Stops current wallet rescan triggered by an RPC call, e.g. by a rescanblockchain call.
1422    /// Note: Use "getwalletinfo" to query the scanning progress.
1423    async fn abort_rescan(&self) -> Result<AbortRescanResponse, Self::Error> {
1424        self.call::<AbortRescanResponse>("abortrescan", &[]).await
1425    }
1426
1427    /// Open an outbound connection to a specified node. This RPC is for testing only.
1428    async fn add_connection(
1429        &self,
1430        address: bitcoin::Address,
1431        connection_type: String,
1432        v2transport: bool,
1433    ) -> Result<AddConnectionResponse, Self::Error> {
1434        let mut rpc_params = vec![];
1435        rpc_params.push(serde_json::json!(address));
1436        rpc_params.push(serde_json::json!(connection_type));
1437        rpc_params.push(serde_json::json!(v2transport));
1438        self.call::<AddConnectionResponse>("addconnection", &rpc_params).await
1439    }
1440
1441    /// Attempts to add or remove a node from the addnode list.
1442    /// Or try a connection to a node once.
1443    /// Nodes added using addnode (or -connect) are protected from DoS disconnection and are not required to be
1444    /// full nodes/support SegWit as other outbound peers are (though such peers will not be synced from).
1445    /// Addnode connections are limited to 8 at a time and are counted separately from the -maxconnections limit.
1446    async fn add_node(
1447        &self,
1448        node: String,
1449        command: String,
1450        v2transport: Option<bool>,
1451    ) -> Result<AddNodeResponse, Self::Error> {
1452        let mut rpc_params = vec![];
1453        rpc_params.push(serde_json::json!(node));
1454        rpc_params.push(serde_json::json!(command));
1455        if let Some(val) = v2transport {
1456            rpc_params.push(serde_json::json!(val));
1457        }
1458        self.call::<AddNodeResponse>("addnode", &rpc_params).await
1459    }
1460
1461    /// Add the address of a potential peer to an address manager table. This RPC is for testing only.
1462    async fn add_peer_address(
1463        &self,
1464        address: bitcoin::Address,
1465        port: i64,
1466        tried: Option<bool>,
1467    ) -> Result<AddPeerAddressResponse, Self::Error> {
1468        let mut rpc_params = vec![];
1469        rpc_params.push(serde_json::json!(address));
1470        rpc_params.push(serde_json::json!(port));
1471        if let Some(val) = tried {
1472            rpc_params.push(serde_json::json!(val));
1473        }
1474        self.call::<AddPeerAddressResponse>("addpeeraddress", &rpc_params).await
1475    }
1476
1477    /// Analyzes and provides information about the current status of a PSBT and its inputs
1478    async fn analyze_psbt(&self, psbt: String) -> Result<AnalyzePsbtResponse, Self::Error> {
1479        let mut rpc_params = vec![];
1480        rpc_params.push(serde_json::json!(psbt));
1481        self.call::<AnalyzePsbtResponse>("analyzepsbt", &rpc_params).await
1482    }
1483
1484    /// Safely copies the current wallet file to the specified destination, which can either be a directory or a path with a filename.
1485    async fn backup_wallet(
1486        &self,
1487        destination: String,
1488    ) -> Result<BackupWalletResponse, Self::Error> {
1489        let mut rpc_params = vec![];
1490        rpc_params.push(serde_json::json!(destination));
1491        self.call::<BackupWalletResponse>("backupwallet", &rpc_params).await
1492    }
1493
1494    /// Bumps the fee of a transaction T, replacing it with a new transaction B.
1495    /// A transaction with the given txid must be in the wallet.
1496    /// The command will pay the additional fee by reducing change outputs or adding inputs when necessary.
1497    /// It may add a new change output if one does not already exist.
1498    /// All inputs in the original transaction will be included in the replacement transaction.
1499    /// The command will fail if the wallet or mempool contains a transaction that spends one of T's outputs.
1500    /// By default, the new fee will be calculated automatically using the estimatesmartfee RPC.
1501    /// The user can specify a confirmation target for estimatesmartfee.
1502    /// Alternatively, the user can specify a fee rate in sat/vB for the new transaction.
1503    /// At a minimum, the new fee rate must be high enough to pay an additional new relay fee (incrementalfee
1504    /// returned by getnetworkinfo) to enter the node's mempool.
1505    /// * WARNING: before version 0.21, fee_rate was in BTC/kvB. As of 0.21, fee_rate is in sat/vB. *
1506    async fn bump_fee(
1507        &self,
1508        txid: bitcoin::Txid,
1509        options: Option<serde_json::Value>,
1510    ) -> Result<BumpFeeResponse, Self::Error> {
1511        let mut rpc_params = vec![];
1512        rpc_params.push(serde_json::json!(txid));
1513        if let Some(val) = options {
1514            rpc_params.push(serde_json::json!(val));
1515        }
1516        self.call::<BumpFeeResponse>("bumpfee", &rpc_params).await
1517    }
1518
1519    /// Clear all banned IPs.
1520    async fn clear_banned(&self) -> Result<ClearBannedResponse, Self::Error> {
1521        self.call::<ClearBannedResponse>("clearbanned", &[]).await
1522    }
1523
1524    /// Combine multiple partially signed Bitcoin transactions into one transaction.
1525    /// Implements the Combiner role.
1526    async fn combine_psbt(
1527        &self,
1528        txs: Vec<serde_json::Value>,
1529    ) -> Result<CombinePsbtResponse, Self::Error> {
1530        let mut rpc_params = vec![];
1531        rpc_params.push(serde_json::json!(txs));
1532        self.call::<CombinePsbtResponse>("combinepsbt", &rpc_params).await
1533    }
1534
1535    /// Combine multiple partially signed transactions into one transaction.
1536    /// The combined transaction may be another partially signed transaction or a
1537    /// fully signed transaction.
1538    async fn combine_raw_transaction(
1539        &self,
1540        txs: Vec<serde_json::Value>,
1541    ) -> Result<CombineRawTransactionResponse, Self::Error> {
1542        let mut rpc_params = vec![];
1543        rpc_params.push(serde_json::json!(txs));
1544        self.call::<CombineRawTransactionResponse>("combinerawtransaction", &rpc_params).await
1545    }
1546
1547    /// Converts a network serialized transaction to a PSBT. This should be used only with createrawtransaction and fundrawtransaction
1548    /// createpsbt and walletcreatefundedpsbt should be used for new applications.
1549    async fn convert_to_psbt(
1550        &self,
1551        hexstring: String,
1552        permitsigdata: Option<bool>,
1553        iswitness: Option<bool>,
1554    ) -> Result<ConvertToPsbtResponse, Self::Error> {
1555        let mut rpc_params = vec![];
1556        rpc_params.push(serde_json::json!(hexstring));
1557        if let Some(val) = permitsigdata {
1558            rpc_params.push(serde_json::json!(val));
1559        }
1560        if let Some(val) = iswitness {
1561            rpc_params.push(serde_json::json!(val));
1562        }
1563        self.call::<ConvertToPsbtResponse>("converttopsbt", &rpc_params).await
1564    }
1565
1566    /// Creates a multi-signature address with n signatures of m keys required.
1567    /// It returns a json object with the address and redeemScript.
1568    async fn create_multisig(
1569        &self,
1570        nrequired: i64,
1571        keys: Vec<serde_json::Value>,
1572        address_type: Option<String>,
1573    ) -> Result<CreateMultisigResponse, Self::Error> {
1574        let mut rpc_params = vec![];
1575        rpc_params.push(serde_json::json!(nrequired));
1576        rpc_params.push(serde_json::json!(keys));
1577        if let Some(val) = address_type {
1578            rpc_params.push(serde_json::json!(val));
1579        }
1580        self.call::<CreateMultisigResponse>("createmultisig", &rpc_params).await
1581    }
1582
1583    /// Creates a transaction in the Partially Signed Transaction format.
1584    /// Implements the Creator role.
1585    /// Note that the transaction's inputs are not signed, and
1586    /// it is not stored in the wallet or transmitted to the network.
1587    async fn create_psbt(
1588        &self,
1589        inputs: Vec<serde_json::Value>,
1590        outputs: Vec<serde_json::Value>,
1591        locktime: Option<i64>,
1592        replaceable: Option<bool>,
1593        version: Option<i64>,
1594    ) -> Result<CreatePsbtResponse, Self::Error> {
1595        let mut rpc_params = vec![];
1596        rpc_params.push(serde_json::json!(inputs));
1597        rpc_params.push(serde_json::json!(outputs));
1598        if let Some(val) = locktime {
1599            rpc_params.push(serde_json::json!(val));
1600        }
1601        if let Some(val) = replaceable {
1602            rpc_params.push(serde_json::json!(val));
1603        }
1604        if let Some(val) = version {
1605            rpc_params.push(serde_json::json!(val));
1606        }
1607        self.call::<CreatePsbtResponse>("createpsbt", &rpc_params).await
1608    }
1609
1610    /// Create a transaction spending the given inputs and creating new outputs.
1611    /// Outputs can be addresses or data.
1612    /// Returns hex-encoded raw transaction.
1613    /// Note that the transaction's inputs are not signed, and
1614    /// it is not stored in the wallet or transmitted to the network.
1615    async fn create_raw_transaction(
1616        &self,
1617        inputs: Vec<serde_json::Value>,
1618        outputs: Vec<serde_json::Value>,
1619        locktime: Option<i64>,
1620        replaceable: Option<bool>,
1621        version: Option<i64>,
1622    ) -> Result<CreateRawTransactionResponse, Self::Error> {
1623        let mut rpc_params = vec![];
1624        rpc_params.push(serde_json::json!(inputs));
1625        rpc_params.push(serde_json::json!(outputs));
1626        if let Some(val) = locktime {
1627            rpc_params.push(serde_json::json!(val));
1628        }
1629        if let Some(val) = replaceable {
1630            rpc_params.push(serde_json::json!(val));
1631        }
1632        if let Some(val) = version {
1633            rpc_params.push(serde_json::json!(val));
1634        }
1635        self.call::<CreateRawTransactionResponse>("createrawtransaction", &rpc_params).await
1636    }
1637
1638    /// Creates and loads a new wallet.
1639    async fn create_wallet(
1640        &self,
1641        wallet_name: String,
1642        disable_private_keys: Option<bool>,
1643        blank: Option<bool>,
1644        passphrase: Option<String>,
1645        avoid_reuse: Option<bool>,
1646        descriptors: Option<bool>,
1647        load_on_startup: Option<bool>,
1648        external_signer: Option<bool>,
1649    ) -> Result<CreateWalletResponse, Self::Error> {
1650        let mut rpc_params = vec![];
1651        rpc_params.push(serde_json::json!(wallet_name));
1652        if let Some(val) = disable_private_keys {
1653            rpc_params.push(serde_json::json!(val));
1654        }
1655        if let Some(val) = blank {
1656            rpc_params.push(serde_json::json!(val));
1657        }
1658        if let Some(val) = passphrase {
1659            rpc_params.push(serde_json::json!(val));
1660        }
1661        if let Some(val) = avoid_reuse {
1662            rpc_params.push(serde_json::json!(val));
1663        }
1664        if let Some(val) = descriptors {
1665            rpc_params.push(serde_json::json!(val));
1666        }
1667        if let Some(val) = load_on_startup {
1668            rpc_params.push(serde_json::json!(val));
1669        }
1670        if let Some(val) = external_signer {
1671            rpc_params.push(serde_json::json!(val));
1672        }
1673        self.call::<CreateWalletResponse>("createwallet", &rpc_params).await
1674    }
1675
1676    /// Creates the wallet's descriptor for the given address type. The address type must be one that the wallet does not already have a descriptor for.
1677    /// Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.
1678    async fn create_wallet_descriptor(
1679        &self,
1680        r#type: String,
1681        options: Option<serde_json::Value>,
1682    ) -> Result<CreateWalletDescriptorResponse, Self::Error> {
1683        let mut rpc_params = vec![];
1684        rpc_params.push(serde_json::json!(r#type));
1685        if let Some(val) = options {
1686            rpc_params.push(serde_json::json!(val));
1687        }
1688        self.call::<CreateWalletDescriptorResponse>("createwalletdescriptor", &rpc_params).await
1689    }
1690
1691    /// Return a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction.
1692    async fn decode_psbt(&self, psbt: String) -> Result<DecodePsbtResponse, Self::Error> {
1693        let mut rpc_params = vec![];
1694        rpc_params.push(serde_json::json!(psbt));
1695        self.call::<DecodePsbtResponse>("decodepsbt", &rpc_params).await
1696    }
1697
1698    /// Return a JSON object representing the serialized, hex-encoded transaction.
1699    async fn decode_raw_transaction(
1700        &self,
1701        hexstring: String,
1702        iswitness: Option<bool>,
1703    ) -> Result<DecodeRawTransactionResponse, Self::Error> {
1704        let mut rpc_params = vec![];
1705        rpc_params.push(serde_json::json!(hexstring));
1706        if let Some(val) = iswitness {
1707            rpc_params.push(serde_json::json!(val));
1708        }
1709        self.call::<DecodeRawTransactionResponse>("decoderawtransaction", &rpc_params).await
1710    }
1711
1712    /// Decode a hex-encoded script.
1713    async fn decode_script(&self, hexstring: String) -> Result<DecodeScriptResponse, Self::Error> {
1714        let mut rpc_params = vec![];
1715        rpc_params.push(serde_json::json!(hexstring));
1716        self.call::<DecodeScriptResponse>("decodescript", &rpc_params).await
1717    }
1718
1719    /// Derives one or more addresses corresponding to an output descriptor.
1720    /// Examples of output descriptors are:
1721    /// pkh(&lt;pubkey&gt;)                                     P2PKH outputs for the given pubkey
1722    /// wpkh(&lt;pubkey&gt;)                                    Native segwit P2PKH outputs for the given pubkey
1723    /// sh(multi(&lt;n&gt;,&lt;pubkey&gt;,&lt;pubkey&gt;,...))              P2SH-multisig outputs for the given threshold and pubkeys
1724    /// raw(&lt;hex script&gt;)                                 Outputs whose output script equals the specified hex-encoded bytes
1725    /// tr(&lt;pubkey&gt;,multi_a(&lt;n&gt;,&lt;pubkey&gt;,&lt;pubkey&gt;,...))   P2TR-multisig outputs for the given threshold and pubkeys
1726    /// In the above, &lt;pubkey&gt; either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one
1727    /// or more path elements separated by "/", where "h" represents a hardened child key.
1728    /// For more information on output descriptors, see the documentation in the doc/descriptors.md file.
1729    async fn derive_addresses(
1730        &self,
1731        descriptor: String,
1732        range: Option<serde_json::Value>,
1733    ) -> Result<DeriveAddressesResponse, Self::Error> {
1734        let mut rpc_params = vec![];
1735        rpc_params.push(serde_json::json!(descriptor));
1736        if let Some(val) = range {
1737            rpc_params.push(serde_json::json!(val));
1738        }
1739        self.call::<DeriveAddressesResponse>("deriveaddresses", &rpc_params).await
1740    }
1741
1742    /// Update all segwit inputs in a PSBT with information from output descriptors, the UTXO set or the mempool.
1743    /// Then, sign the inputs we are able to with information from the output descriptors.
1744    async fn descriptor_process_psbt(
1745        &self,
1746        psbt: String,
1747        descriptors: Vec<serde_json::Value>,
1748        sighashtype: Option<String>,
1749        bip32derivs: Option<bool>,
1750        finalize: Option<bool>,
1751    ) -> Result<DescriptorProcessPsbtResponse, Self::Error> {
1752        let mut rpc_params = vec![];
1753        rpc_params.push(serde_json::json!(psbt));
1754        rpc_params.push(serde_json::json!(descriptors));
1755        if let Some(val) = sighashtype {
1756            rpc_params.push(serde_json::json!(val));
1757        }
1758        if let Some(val) = bip32derivs {
1759            rpc_params.push(serde_json::json!(val));
1760        }
1761        if let Some(val) = finalize {
1762            rpc_params.push(serde_json::json!(val));
1763        }
1764        self.call::<DescriptorProcessPsbtResponse>("descriptorprocesspsbt", &rpc_params).await
1765    }
1766
1767    /// Immediately disconnects from the specified peer node.
1768    /// Strictly one out of 'address' and 'nodeid' can be provided to identify the node.
1769    /// To disconnect by nodeid, either set 'address' to the empty string, or call using the named 'nodeid' argument only.
1770    async fn disconnect_node(
1771        &self,
1772        address: Option<bitcoin::Address>,
1773        nodeid: Option<i64>,
1774    ) -> Result<DisconnectNodeResponse, Self::Error> {
1775        let mut rpc_params = vec![];
1776        if let Some(val) = address {
1777            rpc_params.push(serde_json::json!(val));
1778        }
1779        if let Some(val) = nodeid {
1780            rpc_params.push(serde_json::json!(val));
1781        }
1782        self.call::<DisconnectNodeResponse>("disconnectnode", &rpc_params).await
1783    }
1784
1785    /// Write the serialized UTXO set to a file. This can be used in loadtxoutset afterwards if this snapshot height is supported in the chainparams as well.
1786    /// Unless the "latest" type is requested, the node will roll back to the requested height and network activity will be suspended during this process. Because of this it is discouraged to interact with the node in any other way during the execution of this call to avoid inconsistent results and race conditions, particularly RPCs that interact with blockstorage.
1787    /// This call may take several minutes. Make sure to use no RPC timeout (bitcoin-cli -rpcclienttimeout=0)
1788    async fn dump_txout_set(
1789        &self,
1790        path: String,
1791        r#type: Option<String>,
1792        options: Option<serde_json::Value>,
1793    ) -> Result<DumpTxoutSetResponse, Self::Error> {
1794        let mut rpc_params = vec![];
1795        rpc_params.push(serde_json::json!(path));
1796        if let Some(val) = r#type {
1797            rpc_params.push(serde_json::json!(val));
1798        }
1799        if let Some(val) = options {
1800            rpc_params.push(serde_json::json!(val));
1801        }
1802        self.call::<DumpTxoutSetResponse>("dumptxoutset", &rpc_params).await
1803    }
1804
1805    /// Simply echo back the input arguments. This command is for testing.
1806    /// It will return an internal bug report when arg9='trigger_internal_bug' is passed.
1807    /// The difference between echo and echojson is that echojson has argument conversion enabled in the client-side table in bitcoin-cli and the GUI. There is no server-side difference.
1808    async fn echo(
1809        &self,
1810        arg0: Option<String>,
1811        arg1: Option<String>,
1812        arg2: Option<String>,
1813        arg3: Option<String>,
1814        arg4: Option<String>,
1815        arg5: Option<String>,
1816        arg6: Option<String>,
1817        arg7: Option<String>,
1818        arg8: Option<String>,
1819        arg9: Option<String>,
1820    ) -> Result<EchoResponse, Self::Error> {
1821        let mut rpc_params = vec![];
1822        if let Some(val) = arg0 {
1823            rpc_params.push(serde_json::json!(val));
1824        }
1825        if let Some(val) = arg1 {
1826            rpc_params.push(serde_json::json!(val));
1827        }
1828        if let Some(val) = arg2 {
1829            rpc_params.push(serde_json::json!(val));
1830        }
1831        if let Some(val) = arg3 {
1832            rpc_params.push(serde_json::json!(val));
1833        }
1834        if let Some(val) = arg4 {
1835            rpc_params.push(serde_json::json!(val));
1836        }
1837        if let Some(val) = arg5 {
1838            rpc_params.push(serde_json::json!(val));
1839        }
1840        if let Some(val) = arg6 {
1841            rpc_params.push(serde_json::json!(val));
1842        }
1843        if let Some(val) = arg7 {
1844            rpc_params.push(serde_json::json!(val));
1845        }
1846        if let Some(val) = arg8 {
1847            rpc_params.push(serde_json::json!(val));
1848        }
1849        if let Some(val) = arg9 {
1850            rpc_params.push(serde_json::json!(val));
1851        }
1852        self.call::<EchoResponse>("echo", &rpc_params).await
1853    }
1854
1855    /// Echo back the input argument, passing it through a spawned process in a multiprocess build.
1856    /// This command is for testing.
1857    async fn echoipc(&self, arg: String) -> Result<EchoipcResponse, Self::Error> {
1858        let mut rpc_params = vec![];
1859        rpc_params.push(serde_json::json!(arg));
1860        self.call::<EchoipcResponse>("echoipc", &rpc_params).await
1861    }
1862
1863    /// Simply echo back the input arguments. This command is for testing.
1864    /// It will return an internal bug report when arg9='trigger_internal_bug' is passed.
1865    /// The difference between echo and echojson is that echojson has argument conversion enabled in the client-side table in bitcoin-cli and the GUI. There is no server-side difference.
1866    async fn echojson(
1867        &self,
1868        arg0: Option<String>,
1869        arg1: Option<String>,
1870        arg2: Option<String>,
1871        arg3: Option<String>,
1872        arg4: Option<String>,
1873        arg5: Option<String>,
1874        arg6: Option<String>,
1875        arg7: Option<String>,
1876        arg8: Option<String>,
1877        arg9: Option<String>,
1878    ) -> Result<EchojsonResponse, Self::Error> {
1879        let mut rpc_params = vec![];
1880        if let Some(val) = arg0 {
1881            rpc_params.push(serde_json::json!(val));
1882        }
1883        if let Some(val) = arg1 {
1884            rpc_params.push(serde_json::json!(val));
1885        }
1886        if let Some(val) = arg2 {
1887            rpc_params.push(serde_json::json!(val));
1888        }
1889        if let Some(val) = arg3 {
1890            rpc_params.push(serde_json::json!(val));
1891        }
1892        if let Some(val) = arg4 {
1893            rpc_params.push(serde_json::json!(val));
1894        }
1895        if let Some(val) = arg5 {
1896            rpc_params.push(serde_json::json!(val));
1897        }
1898        if let Some(val) = arg6 {
1899            rpc_params.push(serde_json::json!(val));
1900        }
1901        if let Some(val) = arg7 {
1902            rpc_params.push(serde_json::json!(val));
1903        }
1904        if let Some(val) = arg8 {
1905            rpc_params.push(serde_json::json!(val));
1906        }
1907        if let Some(val) = arg9 {
1908            rpc_params.push(serde_json::json!(val));
1909        }
1910        self.call::<EchojsonResponse>("echojson", &rpc_params).await
1911    }
1912
1913    /// Encrypts the wallet with 'passphrase'. This is for first time encryption.
1914    /// After this, any calls that interact with private keys such as sending or signing
1915    /// will require the passphrase to be set prior to making these calls.
1916    /// Use the walletpassphrase call for this, and then walletlock call.
1917    /// If the wallet is already encrypted, use the walletpassphrasechange call.
1918    /// ** IMPORTANT **
1919    /// For security reasons, the encryption process will generate a new HD seed, resulting
1920    /// in the creation of a fresh set of active descriptors. Therefore, it is crucial to
1921    /// securely back up the newly generated wallet file using the backupwallet RPC.
1922    async fn encrypt_wallet(
1923        &self,
1924        passphrase: String,
1925    ) -> Result<EncryptWalletResponse, Self::Error> {
1926        let mut rpc_params = vec![];
1927        rpc_params.push(serde_json::json!(passphrase));
1928        self.call::<EncryptWalletResponse>("encryptwallet", &rpc_params).await
1929    }
1930
1931    /// Returns a list of external signers from -signer.
1932    async fn enumerate_signers(&self) -> Result<EnumerateSignersResponse, Self::Error> {
1933        self.call::<EnumerateSignersResponse>("enumeratesigners", &[]).await
1934    }
1935
1936    /// WARNING: This interface is unstable and may disappear or change!
1937    /// WARNING: This is an advanced API call that is tightly coupled to the specific
1938    /// implementation of fee estimation. The parameters it can be called with
1939    /// and the results it returns will change if the internal implementation changes.
1940    /// Estimates the approximate fee per kilobyte needed for a transaction to begin
1941    /// confirmation within conf_target blocks if possible. Uses virtual transaction size as
1942    /// defined in BIP 141 (witness data is discounted).
1943    async fn estimate_raw_fee(
1944        &self,
1945        conf_target: i64,
1946        threshold: Option<i64>,
1947    ) -> Result<EstimateRawFeeResponse, Self::Error> {
1948        let mut rpc_params = vec![];
1949        rpc_params.push(serde_json::json!(conf_target));
1950        if let Some(val) = threshold {
1951            rpc_params.push(serde_json::json!(val));
1952        }
1953        self.call::<EstimateRawFeeResponse>("estimaterawfee", &rpc_params).await
1954    }
1955
1956    /// Estimates the approximate fee per kilobyte needed for a transaction to begin
1957    /// confirmation within conf_target blocks if possible and return the number of blocks
1958    /// for which the estimate is valid. Uses virtual transaction size as defined
1959    /// in BIP 141 (witness data is discounted).
1960    async fn estimate_smart_fee(
1961        &self,
1962        conf_target: i64,
1963        estimate_mode: Option<String>,
1964    ) -> Result<EstimateSmartFeeResponse, Self::Error> {
1965        let mut rpc_params = vec![];
1966        rpc_params.push(serde_json::json!(conf_target));
1967        if let Some(val) = estimate_mode {
1968            rpc_params.push(serde_json::json!(val));
1969        }
1970        self.call::<EstimateSmartFeeResponse>("estimatesmartfee", &rpc_params).await
1971    }
1972
1973    /// Finalize the inputs of a PSBT. If the transaction is fully signed, it will produce a
1974    /// network serialized transaction which can be broadcast with sendrawtransaction. Otherwise a PSBT will be
1975    /// created which has the final_scriptSig and final_scriptwitness fields filled for inputs that are complete.
1976    /// Implements the Finalizer and Extractor roles.
1977    async fn finalize_psbt(
1978        &self,
1979        psbt: String,
1980        extract: Option<bool>,
1981    ) -> Result<FinalizePsbtResponse, Self::Error> {
1982        let mut rpc_params = vec![];
1983        rpc_params.push(serde_json::json!(psbt));
1984        if let Some(val) = extract {
1985            rpc_params.push(serde_json::json!(val));
1986        }
1987        self.call::<FinalizePsbtResponse>("finalizepsbt", &rpc_params).await
1988    }
1989
1990    /// If the transaction has no inputs, they will be automatically selected to meet its out value.
1991    /// It will add at most one change output to the outputs.
1992    /// No existing outputs will be modified unless "subtractFeeFromOutputs" is specified.
1993    /// Note that inputs which were signed may need to be resigned after completion since in/outputs have been added.
1994    /// The inputs added will not be signed, use signrawtransactionwithkey
1995    /// or signrawtransactionwithwallet for that.
1996    /// All existing inputs must either have their previous output transaction be in the wallet
1997    /// or be in the UTXO set. Solving data must be provided for non-wallet inputs.
1998    /// Note that all inputs selected must be of standard form and P2SH scripts must be
1999    /// in the wallet using importdescriptors (to calculate fees).
2000    /// You can see whether this is the case by checking the "solvable" field in the listunspent output.
2001    /// Note that if specifying an exact fee rate, the resulting transaction may have a higher fee rate
2002    /// if the transaction has unconfirmed inputs. This is because the wallet will attempt to make the
2003    /// entire package have the given fee rate, not the resulting transaction.
2004    async fn fund_raw_transaction(
2005        &self,
2006        hexstring: String,
2007        options: Option<serde_json::Value>,
2008        iswitness: Option<bool>,
2009    ) -> Result<FundRawTransactionResponse, Self::Error> {
2010        let mut rpc_params = vec![];
2011        rpc_params.push(serde_json::json!(hexstring));
2012        if let Some(val) = options {
2013            rpc_params.push(serde_json::json!(val));
2014        }
2015        if let Some(val) = iswitness {
2016            rpc_params.push(serde_json::json!(val));
2017        }
2018        self.call::<FundRawTransactionResponse>("fundrawtransaction", &rpc_params).await
2019    }
2020
2021    /// has been replaced by the -generate cli option. Refer to -help for more information.
2022    async fn generate(&self) -> Result<(), Self::Error> { self.call::<()>("generate", &[]).await }
2023
2024    /// Mine a set of ordered transactions to a specified address or descriptor and return the block hash.
2025    async fn generate_block(
2026        &self,
2027        output: String,
2028        transactions: Vec<serde_json::Value>,
2029        submit: Option<bool>,
2030    ) -> Result<GenerateBlockResponse, Self::Error> {
2031        let mut rpc_params = vec![];
2032        rpc_params.push(serde_json::json!(output));
2033        rpc_params.push(serde_json::json!(transactions));
2034        if let Some(val) = submit {
2035            rpc_params.push(serde_json::json!(val));
2036        }
2037        self.call::<GenerateBlockResponse>("generateblock", &rpc_params).await
2038    }
2039
2040    /// Mine to a specified address and return the block hashes.
2041    async fn generate_to_address(
2042        &self,
2043        nblocks: i64,
2044        address: bitcoin::Address,
2045        maxtries: Option<i64>,
2046    ) -> Result<GenerateToAddressResponse, Self::Error> {
2047        let mut rpc_params = vec![];
2048        rpc_params.push(serde_json::json!(nblocks));
2049        rpc_params.push(serde_json::json!(address));
2050        if let Some(val) = maxtries {
2051            rpc_params.push(serde_json::json!(val));
2052        }
2053        self.call::<GenerateToAddressResponse>("generatetoaddress", &rpc_params).await
2054    }
2055
2056    /// Mine to a specified descriptor and return the block hashes.
2057    async fn generate_to_descriptor(
2058        &self,
2059        num_blocks: i64,
2060        descriptor: String,
2061        maxtries: Option<i64>,
2062    ) -> Result<GenerateToDescriptorResponse, Self::Error> {
2063        let mut rpc_params = vec![];
2064        rpc_params.push(serde_json::json!(num_blocks));
2065        rpc_params.push(serde_json::json!(descriptor));
2066        if let Some(val) = maxtries {
2067            rpc_params.push(serde_json::json!(val));
2068        }
2069        self.call::<GenerateToDescriptorResponse>("generatetodescriptor", &rpc_params).await
2070    }
2071
2072    /// Returns information about the given added node, or all added nodes
2073    /// (note that onetry addnodes are not listed here)
2074    async fn get_added_node_info(
2075        &self,
2076        node: Option<String>,
2077    ) -> Result<GetAddedNodeInfoResponse, Self::Error> {
2078        let mut rpc_params = vec![];
2079        if let Some(val) = node {
2080            rpc_params.push(serde_json::json!(val));
2081        }
2082        self.call::<GetAddedNodeInfoResponse>("getaddednodeinfo", &rpc_params).await
2083    }
2084
2085    /// Returns the list of addresses assigned the specified label.
2086    async fn get_addresses_by_label(
2087        &self,
2088        label: String,
2089    ) -> Result<GetAddressesByLabelResponse, Self::Error> {
2090        let mut rpc_params = vec![];
2091        rpc_params.push(serde_json::json!(label));
2092        self.call::<GetAddressesByLabelResponse>("getaddressesbylabel", &rpc_params).await
2093    }
2094
2095    /// Return information about the given bitcoin address.
2096    /// Some of the information will only be present if the address is in the active wallet.
2097    async fn get_address_info(
2098        &self,
2099        address: bitcoin::Address,
2100    ) -> Result<GetAddressInfoResponse, Self::Error> {
2101        let mut rpc_params = vec![];
2102        rpc_params.push(serde_json::json!(address));
2103        self.call::<GetAddressInfoResponse>("getaddressinfo", &rpc_params).await
2104    }
2105
2106    /// Provides information about the node's address manager by returning the number of addresses in the `new` and `tried` tables and their sum for all networks.
2107    async fn get_addrman_info(&self) -> Result<GetAddrmanInfoResponse, Self::Error> {
2108        self.call::<GetAddrmanInfoResponse>("getaddrmaninfo", &[]).await
2109    }
2110
2111    /// Returns the total available balance.
2112    /// The available balance is what the wallet considers currently spendable, and is
2113    /// thus affected by options which limit spendability such as -spendzeroconfchange.
2114    async fn get_balance(
2115        &self,
2116        dummy: Option<String>,
2117        minconf: Option<i64>,
2118        include_watchonly: Option<bool>,
2119        avoid_reuse: Option<bool>,
2120    ) -> Result<GetBalanceResponse, Self::Error> {
2121        let mut rpc_params = vec![];
2122        if let Some(val) = dummy {
2123            rpc_params.push(serde_json::json!(val));
2124        }
2125        if let Some(val) = minconf {
2126            rpc_params.push(serde_json::json!(val));
2127        }
2128        if let Some(val) = include_watchonly {
2129            rpc_params.push(serde_json::json!(val));
2130        }
2131        if let Some(val) = avoid_reuse {
2132            rpc_params.push(serde_json::json!(val));
2133        }
2134        self.call::<GetBalanceResponse>("getbalance", &rpc_params).await
2135    }
2136
2137    /// Returns an object with all balances in BTC.
2138    async fn get_balances(&self) -> Result<GetBalancesResponse, Self::Error> {
2139        self.call::<GetBalancesResponse>("getbalances", &[]).await
2140    }
2141
2142    /// Returns the hash of the best (tip) block in the most-work fully-validated chain.
2143    async fn get_best_block_hash(&self) -> Result<GetBestBlockHashResponse, Self::Error> {
2144        self.call::<GetBestBlockHashResponse>("getbestblockhash", &[]).await
2145    }
2146
2147    /// If verbosity is 0, returns a string that is serialized, hex-encoded data for block 'hash'.
2148    /// If verbosity is 1, returns an Object with information about block &lt;hash&gt;.
2149    /// If verbosity is 2, returns an Object with information about block &lt;hash&gt; and information about each transaction.
2150    /// If verbosity is 3, returns an Object with information about block &lt;hash&gt; and information about each transaction, including prevout information for inputs (only for unpruned blocks in the current best chain).
2151    async fn get_block(
2152        &self,
2153        blockhash: bitcoin::BlockHash,
2154        verbosity: Option<i64>,
2155    ) -> Result<GetBlockResponse, Self::Error> {
2156        let mut rpc_params = vec![];
2157        rpc_params.push(serde_json::json!(blockhash));
2158        if let Some(val) = verbosity {
2159            rpc_params.push(serde_json::json!(val));
2160        }
2161        self.call::<GetBlockResponse>("getblock", &rpc_params).await
2162    }
2163
2164    /// Returns an object containing various state info regarding blockchain processing.
2165    async fn get_blockchain_info(&self) -> Result<GetBlockchainInfoResponse, Self::Error> {
2166        self.call::<GetBlockchainInfoResponse>("getblockchaininfo", &[]).await
2167    }
2168
2169    /// Returns the height of the most-work fully-validated chain.
2170    /// The genesis block has height 0.
2171    async fn get_block_count(&self) -> Result<GetBlockCountResponse, Self::Error> {
2172        self.call::<GetBlockCountResponse>("getblockcount", &[]).await
2173    }
2174
2175    /// Retrieve a BIP 157 content filter for a particular block.
2176    async fn get_block_filter(
2177        &self,
2178        blockhash: bitcoin::BlockHash,
2179        filtertype: Option<String>,
2180    ) -> Result<GetBlockFilterResponse, Self::Error> {
2181        let mut rpc_params = vec![];
2182        rpc_params.push(serde_json::json!(blockhash));
2183        if let Some(val) = filtertype {
2184            rpc_params.push(serde_json::json!(val));
2185        }
2186        self.call::<GetBlockFilterResponse>("getblockfilter", &rpc_params).await
2187    }
2188
2189    /// Attempt to fetch block from a given peer.
2190    /// We must have the header for this block, e.g. using submitheader.
2191    /// The block will not have any undo data which can limit the usage of the block data in a context where the undo data is needed.
2192    /// Subsequent calls for the same block may cause the response from the previous peer to be ignored.
2193    /// Peers generally ignore requests for a stale block that they never fully verified, or one that is more than a month old.
2194    /// When a peer does not respond with a block, we will disconnect.
2195    /// Note: The block could be re-pruned as soon as it is received.
2196    /// Returns an empty JSON object if the request was successfully scheduled.
2197    async fn get_block_from_peer(
2198        &self,
2199        blockhash: bitcoin::BlockHash,
2200        peer_id: i64,
2201    ) -> Result<GetBlockFromPeerResponse, Self::Error> {
2202        let mut rpc_params = vec![];
2203        rpc_params.push(serde_json::json!(blockhash));
2204        rpc_params.push(serde_json::json!(peer_id));
2205        self.call::<GetBlockFromPeerResponse>("getblockfrompeer", &rpc_params).await
2206    }
2207
2208    /// Returns hash of block in best-block-chain at height provided.
2209    async fn get_block_hash(&self, height: i64) -> Result<GetBlockHashResponse, Self::Error> {
2210        let mut rpc_params = vec![];
2211        rpc_params.push(serde_json::json!(height));
2212        self.call::<GetBlockHashResponse>("getblockhash", &rpc_params).await
2213    }
2214
2215    /// If verbose is false, returns a string that is serialized, hex-encoded data for blockheader 'hash'.
2216    /// If verbose is true, returns an Object with information about blockheader &lt;hash&gt;.
2217    async fn get_block_header(
2218        &self,
2219        blockhash: bitcoin::BlockHash,
2220        verbose: Option<bool>,
2221    ) -> Result<GetBlockHeaderResponse, Self::Error> {
2222        let mut rpc_params = vec![];
2223        rpc_params.push(serde_json::json!(blockhash));
2224        if let Some(val) = verbose {
2225            rpc_params.push(serde_json::json!(val));
2226        }
2227        self.call::<GetBlockHeaderResponse>("getblockheader", &rpc_params).await
2228    }
2229
2230    /// Compute per block statistics for a given window. All amounts are in satoshis.
2231    /// It won't work for some heights with pruning.
2232    async fn get_block_stats(
2233        &self,
2234        hash_or_height: i64,
2235        stats: Option<Vec<serde_json::Value>>,
2236    ) -> Result<GetBlockStatsResponse, Self::Error> {
2237        let mut rpc_params = vec![];
2238        rpc_params.push(serde_json::json!(hash_or_height));
2239        if let Some(val) = stats {
2240            rpc_params.push(serde_json::json!(val));
2241        }
2242        self.call::<GetBlockStatsResponse>("getblockstats", &rpc_params).await
2243    }
2244
2245    /// If the request parameters include a 'mode' key, that is used to explicitly select between the default 'template' request or a 'proposal'.
2246    /// It returns data needed to construct a block to work on.
2247    /// For full specification, see BIPs 22, 23, 9, and 145:
2248    /// <https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki>
2249    /// <https://github.com/bitcoin/bips/blob/master/bip-0023.mediawiki>
2250    /// <https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes>
2251    /// <https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki>
2252    async fn get_block_template(
2253        &self,
2254        template_request: serde_json::Value,
2255    ) -> Result<GetBlockTemplateResponse, Self::Error> {
2256        let mut rpc_params = vec![];
2257        rpc_params.push(serde_json::json!(template_request));
2258        self.call::<GetBlockTemplateResponse>("getblocktemplate", &rpc_params).await
2259    }
2260
2261    /// Return information about chainstates.
2262    async fn get_chain_states(&self) -> Result<GetChainStatesResponse, Self::Error> {
2263        self.call::<GetChainStatesResponse>("getchainstates", &[]).await
2264    }
2265
2266    /// Return information about all known tips in the block tree, including the main chain as well as orphaned branches.
2267    async fn get_chain_tips(&self) -> Result<GetChainTipsResponse, Self::Error> {
2268        self.call::<GetChainTipsResponse>("getchaintips", &[]).await
2269    }
2270
2271    /// Compute statistics about the total number and rate of transactions in the chain.
2272    async fn get_chain_tx_stats(
2273        &self,
2274        nblocks: Option<i64>,
2275        blockhash: Option<bitcoin::BlockHash>,
2276    ) -> Result<GetChainTxStatsResponse, Self::Error> {
2277        let mut rpc_params = vec![];
2278        if let Some(val) = nblocks {
2279            rpc_params.push(serde_json::json!(val));
2280        }
2281        if let Some(val) = blockhash {
2282            rpc_params.push(serde_json::json!(val));
2283        }
2284        self.call::<GetChainTxStatsResponse>("getchaintxstats", &rpc_params).await
2285    }
2286
2287    /// Returns the number of connections to other nodes.
2288    async fn get_connection_count(&self) -> Result<GetConnectionCountResponse, Self::Error> {
2289        self.call::<GetConnectionCountResponse>("getconnectioncount", &[]).await
2290    }
2291
2292    /// Returns an object containing various state info regarding deployments of consensus changes.
2293    async fn get_deployment_info(
2294        &self,
2295        blockhash: Option<bitcoin::BlockHash>,
2296    ) -> Result<GetDeploymentInfoResponse, Self::Error> {
2297        let mut rpc_params = vec![];
2298        if let Some(val) = blockhash {
2299            rpc_params.push(serde_json::json!(val));
2300        }
2301        self.call::<GetDeploymentInfoResponse>("getdeploymentinfo", &rpc_params).await
2302    }
2303
2304    /// Get spend and receive activity associated with a set of descriptors for a set of blocks. This command pairs well with the `relevant_blocks` output of `scanblocks()`.
2305    /// This call may take several minutes. If you encounter timeouts, try specifying no RPC timeout (bitcoin-cli -rpcclienttimeout=0)
2306    async fn get_descriptor_activity(
2307        &self,
2308        blockhashes: Vec<serde_json::Value>,
2309        scanobjects: Vec<serde_json::Value>,
2310        include_mempool: Option<bool>,
2311    ) -> Result<GetDescriptorActivityResponse, Self::Error> {
2312        let mut rpc_params = vec![];
2313        rpc_params.push(serde_json::json!(blockhashes));
2314        rpc_params.push(serde_json::json!(scanobjects));
2315        if let Some(val) = include_mempool {
2316            rpc_params.push(serde_json::json!(val));
2317        }
2318        self.call::<GetDescriptorActivityResponse>("getdescriptoractivity", &rpc_params).await
2319    }
2320
2321    /// Analyses a descriptor.
2322    async fn get_descriptor_info(
2323        &self,
2324        descriptor: String,
2325    ) -> Result<GetDescriptorInfoResponse, Self::Error> {
2326        let mut rpc_params = vec![];
2327        rpc_params.push(serde_json::json!(descriptor));
2328        self.call::<GetDescriptorInfoResponse>("getdescriptorinfo", &rpc_params).await
2329    }
2330
2331    /// Returns the proof-of-work difficulty as a multiple of the minimum difficulty.
2332    async fn get_difficulty(&self) -> Result<GetDifficultyResponse, Self::Error> {
2333        self.call::<GetDifficultyResponse>("getdifficulty", &[]).await
2334    }
2335
2336    /// List all BIP 32 HD keys in the wallet and which descriptors use them.
2337    async fn get_hd_keys(
2338        &self,
2339        options: Option<serde_json::Value>,
2340    ) -> Result<GetHdKeysResponse, Self::Error> {
2341        let mut rpc_params = vec![];
2342        if let Some(val) = options {
2343            rpc_params.push(serde_json::json!(val));
2344        }
2345        self.call::<GetHdKeysResponse>("gethdkeys", &rpc_params).await
2346    }
2347
2348    /// Returns the status of one or all available indices currently running in the node.
2349    async fn get_index_info(
2350        &self,
2351        index_name: Option<String>,
2352    ) -> Result<GetIndexInfoResponse, Self::Error> {
2353        let mut rpc_params = vec![];
2354        if let Some(val) = index_name {
2355            rpc_params.push(serde_json::json!(val));
2356        }
2357        self.call::<GetIndexInfoResponse>("getindexinfo", &rpc_params).await
2358    }
2359
2360    /// Returns an object containing information about memory usage.
2361    async fn get_memory_info(
2362        &self,
2363        mode: Option<String>,
2364    ) -> Result<GetMemoryInfoResponse, Self::Error> {
2365        let mut rpc_params = vec![];
2366        if let Some(val) = mode {
2367            rpc_params.push(serde_json::json!(val));
2368        }
2369        self.call::<GetMemoryInfoResponse>("getmemoryinfo", &rpc_params).await
2370    }
2371
2372    /// If txid is in the mempool, returns all in-mempool ancestors.
2373    async fn get_mempool_ancestors(
2374        &self,
2375        txid: bitcoin::Txid,
2376        verbose: Option<bool>,
2377    ) -> Result<GetMempoolAncestorsResponse, Self::Error> {
2378        let mut rpc_params = vec![];
2379        rpc_params.push(serde_json::json!(txid));
2380        if let Some(val) = verbose {
2381            rpc_params.push(serde_json::json!(val));
2382        }
2383        self.call::<GetMempoolAncestorsResponse>("getmempoolancestors", &rpc_params).await
2384    }
2385
2386    /// Returns mempool data for given cluster
2387    async fn get_mempool_cluster(
2388        &self,
2389        txid: bitcoin::Txid,
2390    ) -> Result<GetMempoolClusterResponse, Self::Error> {
2391        let mut rpc_params = vec![];
2392        rpc_params.push(serde_json::json!(txid));
2393        self.call::<GetMempoolClusterResponse>("getmempoolcluster", &rpc_params).await
2394    }
2395
2396    /// If txid is in the mempool, returns all in-mempool descendants.
2397    async fn get_mempool_descendants(
2398        &self,
2399        txid: bitcoin::Txid,
2400        verbose: Option<bool>,
2401    ) -> Result<GetMempoolDescendantsResponse, Self::Error> {
2402        let mut rpc_params = vec![];
2403        rpc_params.push(serde_json::json!(txid));
2404        if let Some(val) = verbose {
2405            rpc_params.push(serde_json::json!(val));
2406        }
2407        self.call::<GetMempoolDescendantsResponse>("getmempooldescendants", &rpc_params).await
2408    }
2409
2410    /// Returns mempool data for given transaction
2411    async fn get_mempool_entry(
2412        &self,
2413        txid: bitcoin::Txid,
2414    ) -> Result<GetMempoolEntryResponse, Self::Error> {
2415        let mut rpc_params = vec![];
2416        rpc_params.push(serde_json::json!(txid));
2417        self.call::<GetMempoolEntryResponse>("getmempoolentry", &rpc_params).await
2418    }
2419
2420    /// Returns the feerate diagram for the whole mempool.
2421    async fn get_mempool_fee_rate_diagram(
2422        &self,
2423    ) -> Result<GetMempoolFeeRateDiagramResponse, Self::Error> {
2424        self.call::<GetMempoolFeeRateDiagramResponse>("getmempoolfeeratediagram", &[]).await
2425    }
2426
2427    /// Returns details on the active state of the TX memory pool.
2428    async fn get_mempool_info(&self) -> Result<GetMempoolInfoResponse, Self::Error> {
2429        self.call::<GetMempoolInfoResponse>("getmempoolinfo", &[]).await
2430    }
2431
2432    /// Returns a json object containing mining-related information.
2433    async fn get_mining_info(&self) -> Result<GetMiningInfoResponse, Self::Error> {
2434        self.call::<GetMiningInfoResponse>("getmininginfo", &[]).await
2435    }
2436
2437    /// Returns information about network traffic, including bytes in, bytes out,
2438    /// and current system time.
2439    async fn get_net_totals(&self) -> Result<GetNetTotalsResponse, Self::Error> {
2440        self.call::<GetNetTotalsResponse>("getnettotals", &[]).await
2441    }
2442
2443    /// Returns the estimated network hashes per second based on the last n blocks.
2444    /// Pass in \[blocks\] to override # of blocks, -1 specifies since last difficulty change.
2445    /// Pass in \[height\] to estimate the network speed at the time when a certain block was found.
2446    async fn get_network_hashps(
2447        &self,
2448        nblocks: Option<i64>,
2449        height: Option<i64>,
2450    ) -> Result<GetNetworkHashpsResponse, Self::Error> {
2451        let mut rpc_params = vec![];
2452        if let Some(val) = nblocks {
2453            rpc_params.push(serde_json::json!(val));
2454        }
2455        if let Some(val) = height {
2456            rpc_params.push(serde_json::json!(val));
2457        }
2458        self.call::<GetNetworkHashpsResponse>("getnetworkhashps", &rpc_params).await
2459    }
2460
2461    /// Returns an object containing various state info regarding P2P networking.
2462    async fn get_network_info(&self) -> Result<GetNetworkInfoResponse, Self::Error> {
2463        self.call::<GetNetworkInfoResponse>("getnetworkinfo", &[]).await
2464    }
2465
2466    /// Returns a new Bitcoin address for receiving payments.
2467    /// If 'label' is specified, it is added to the address book
2468    /// so payments received with the address will be associated with 'label'.
2469    async fn get_new_address(
2470        &self,
2471        label: Option<String>,
2472        address_type: Option<String>,
2473    ) -> Result<GetNewAddressResponse, Self::Error> {
2474        let mut rpc_params = vec![];
2475        if let Some(val) = label {
2476            rpc_params.push(serde_json::json!(val));
2477        }
2478        if let Some(val) = address_type {
2479            rpc_params.push(serde_json::json!(val));
2480        }
2481        self.call::<GetNewAddressResponse>("getnewaddress", &rpc_params).await
2482    }
2483
2484    /// Return known addresses, after filtering for quality and recency.
2485    /// These can potentially be used to find new peers in the network.
2486    /// The total number of addresses known to the node may be higher.
2487    async fn get_node_addresses(
2488        &self,
2489        count: Option<i64>,
2490        network: Option<String>,
2491    ) -> Result<GetNodeAddressesResponse, Self::Error> {
2492        let mut rpc_params = vec![];
2493        if let Some(val) = count {
2494            rpc_params.push(serde_json::json!(val));
2495        }
2496        if let Some(val) = network {
2497            rpc_params.push(serde_json::json!(val));
2498        }
2499        self.call::<GetNodeAddressesResponse>("getnodeaddresses", &rpc_params).await
2500    }
2501
2502    /// Shows transactions in the tx orphanage.
2503    /// EXPERIMENTAL warning: this call may be changed in future releases.
2504    async fn get_orphan_txs(
2505        &self,
2506        verbosity: Option<i64>,
2507    ) -> Result<GetOrphanTxsResponse, Self::Error> {
2508        let mut rpc_params = vec![];
2509        if let Some(val) = verbosity {
2510            rpc_params.push(serde_json::json!(val));
2511        }
2512        self.call::<GetOrphanTxsResponse>("getorphantxs", &rpc_params).await
2513    }
2514
2515    /// Returns data about each connected network peer as a json array of objects.
2516    async fn get_peer_info(&self) -> Result<GetPeerInfoResponse, Self::Error> {
2517        self.call::<GetPeerInfoResponse>("getpeerinfo", &[]).await
2518    }
2519
2520    /// Returns a map of all user-created (see prioritisetransaction) fee deltas by txid, and whether the tx is present in mempool.
2521    async fn get_prioritised_transactions(
2522        &self,
2523    ) -> Result<GetPrioritisedTransactionsResponse, Self::Error> {
2524        self.call::<GetPrioritisedTransactionsResponse>("getprioritisedtransactions", &[]).await
2525    }
2526
2527    /// EXPERIMENTAL warning: this call may be changed in future releases.
2528    /// Returns information on all address manager entries for the new and tried tables.
2529    async fn get_raw_addrman(&self) -> Result<GetRawAddrmanResponse, Self::Error> {
2530        self.call::<GetRawAddrmanResponse>("getrawaddrman", &[]).await
2531    }
2532
2533    /// Returns a new Bitcoin address, for receiving change.
2534    /// This is for use with raw transactions, NOT normal use.
2535    async fn get_raw_change_address(
2536        &self,
2537        address_type: Option<String>,
2538    ) -> Result<GetRawChangeAddressResponse, Self::Error> {
2539        let mut rpc_params = vec![];
2540        if let Some(val) = address_type {
2541            rpc_params.push(serde_json::json!(val));
2542        }
2543        self.call::<GetRawChangeAddressResponse>("getrawchangeaddress", &rpc_params).await
2544    }
2545
2546    /// Returns all transaction ids in memory pool as a json array of string transaction ids.
2547    /// Hint: use getmempoolentry to fetch a specific transaction from the mempool.
2548    async fn get_raw_mempool(
2549        &self,
2550        verbose: Option<bool>,
2551        mempool_sequence: Option<bool>,
2552    ) -> Result<GetRawMempoolResponse, Self::Error> {
2553        let mut rpc_params = vec![];
2554        if let Some(val) = verbose {
2555            rpc_params.push(serde_json::json!(val));
2556        }
2557        if let Some(val) = mempool_sequence {
2558            rpc_params.push(serde_json::json!(val));
2559        }
2560        self.call::<GetRawMempoolResponse>("getrawmempool", &rpc_params).await
2561    }
2562
2563    /// By default, this call only returns a transaction if it is in the mempool. If -txindex is enabled
2564    /// and no blockhash argument is passed, it will return the transaction if it is in the mempool or any block.
2565    /// If a blockhash argument is passed, it will return the transaction if
2566    /// the specified block is available and the transaction is in that block.
2567    /// Hint: Use gettransaction for wallet transactions.
2568    /// If verbosity is 0 or omitted, returns the serialized transaction as a hex-encoded string.
2569    /// If verbosity is 1, returns a JSON Object with information about the transaction.
2570    /// If verbosity is 2, returns a JSON Object with information about the transaction, including fee and prevout information.
2571    async fn get_raw_transaction(
2572        &self,
2573        txid: bitcoin::Txid,
2574        verbosity: Option<i64>,
2575        blockhash: Option<bitcoin::BlockHash>,
2576    ) -> Result<GetRawTransactionResponse, Self::Error> {
2577        let mut rpc_params = vec![];
2578        rpc_params.push(serde_json::json!(txid));
2579        if let Some(val) = verbosity {
2580            rpc_params.push(serde_json::json!(val));
2581        }
2582        if let Some(val) = blockhash {
2583            rpc_params.push(serde_json::json!(val));
2584        }
2585        self.call::<GetRawTransactionResponse>("getrawtransaction", &rpc_params).await
2586    }
2587
2588    /// Returns the total amount received by the given address in transactions with at least minconf confirmations.
2589    async fn get_received_by_address(
2590        &self,
2591        address: bitcoin::Address,
2592        minconf: Option<i64>,
2593        include_immature_coinbase: Option<bool>,
2594    ) -> Result<GetReceivedByAddressResponse, Self::Error> {
2595        let mut rpc_params = vec![];
2596        rpc_params.push(serde_json::json!(address));
2597        if let Some(val) = minconf {
2598            rpc_params.push(serde_json::json!(val));
2599        }
2600        if let Some(val) = include_immature_coinbase {
2601            rpc_params.push(serde_json::json!(val));
2602        }
2603        self.call::<GetReceivedByAddressResponse>("getreceivedbyaddress", &rpc_params).await
2604    }
2605
2606    /// Returns the total amount received by addresses with &lt;label&gt; in transactions with at least \[minconf\] confirmations.
2607    async fn get_received_by_label(
2608        &self,
2609        label: String,
2610        minconf: Option<i64>,
2611        include_immature_coinbase: Option<bool>,
2612    ) -> Result<GetReceivedByLabelResponse, Self::Error> {
2613        let mut rpc_params = vec![];
2614        rpc_params.push(serde_json::json!(label));
2615        if let Some(val) = minconf {
2616            rpc_params.push(serde_json::json!(val));
2617        }
2618        if let Some(val) = include_immature_coinbase {
2619            rpc_params.push(serde_json::json!(val));
2620        }
2621        self.call::<GetReceivedByLabelResponse>("getreceivedbylabel", &rpc_params).await
2622    }
2623
2624    /// Returns details of the RPC server.
2625    async fn get_rpc_info(&self) -> Result<GetRpcInfoResponse, Self::Error> {
2626        self.call::<GetRpcInfoResponse>("getrpcinfo", &[]).await
2627    }
2628
2629    /// Get detailed information about in-wallet transaction &lt;txid&gt;
2630    async fn get_transaction(
2631        &self,
2632        txid: bitcoin::Txid,
2633        include_watchonly: Option<bool>,
2634        verbose: Option<bool>,
2635    ) -> Result<GetTransactionResponse, Self::Error> {
2636        let mut rpc_params = vec![];
2637        rpc_params.push(serde_json::json!(txid));
2638        if let Some(val) = include_watchonly {
2639            rpc_params.push(serde_json::json!(val));
2640        }
2641        if let Some(val) = verbose {
2642            rpc_params.push(serde_json::json!(val));
2643        }
2644        self.call::<GetTransactionResponse>("gettransaction", &rpc_params).await
2645    }
2646
2647    /// Returns details about an unspent transaction output.
2648    async fn get_txout(
2649        &self,
2650        txid: bitcoin::Txid,
2651        n: i64,
2652        include_mempool: Option<bool>,
2653    ) -> Result<GetTxoutResponse, Self::Error> {
2654        let mut rpc_params = vec![];
2655        rpc_params.push(serde_json::json!(txid));
2656        rpc_params.push(serde_json::json!(n));
2657        if let Some(val) = include_mempool {
2658            rpc_params.push(serde_json::json!(val));
2659        }
2660        self.call::<GetTxoutResponse>("gettxout", &rpc_params).await
2661    }
2662
2663    /// Returns a hex-encoded proof that "txid" was included in a block.
2664    /// NOTE: By default this function only works sometimes. This is when there is an
2665    /// unspent output in the utxo for this transaction. To make it always work,
2666    /// you need to maintain a transaction index, using the -txindex command line option or
2667    /// specify the block in which the transaction is included manually (by blockhash).
2668    async fn get_txout_proof(
2669        &self,
2670        txids: Vec<serde_json::Value>,
2671        blockhash: Option<bitcoin::BlockHash>,
2672    ) -> Result<GetTxoutProofResponse, Self::Error> {
2673        let mut rpc_params = vec![];
2674        rpc_params.push(serde_json::json!(txids));
2675        if let Some(val) = blockhash {
2676            rpc_params.push(serde_json::json!(val));
2677        }
2678        self.call::<GetTxoutProofResponse>("gettxoutproof", &rpc_params).await
2679    }
2680
2681    /// Returns statistics about the unspent transaction output set.
2682    /// Note this call may take some time if you are not using coinstatsindex.
2683    async fn get_txout_set_info(
2684        &self,
2685        hash_type: Option<String>,
2686        hash_or_height: Option<i64>,
2687        use_index: Option<bool>,
2688    ) -> Result<GetTxoutSetInfoResponse, Self::Error> {
2689        let mut rpc_params = vec![];
2690        if let Some(val) = hash_type {
2691            rpc_params.push(serde_json::json!(val));
2692        }
2693        if let Some(val) = hash_or_height {
2694            rpc_params.push(serde_json::json!(val));
2695        }
2696        if let Some(val) = use_index {
2697            rpc_params.push(serde_json::json!(val));
2698        }
2699        self.call::<GetTxoutSetInfoResponse>("gettxoutsetinfo", &rpc_params).await
2700    }
2701
2702    /// Scans the mempool to find transactions spending any of the given outputs
2703    async fn get_tx_spending_prevout(
2704        &self,
2705        outputs: Vec<serde_json::Value>,
2706    ) -> Result<GetTxSpendingPrevoutResponse, Self::Error> {
2707        let mut rpc_params = vec![];
2708        rpc_params.push(serde_json::json!(outputs));
2709        self.call::<GetTxSpendingPrevoutResponse>("gettxspendingprevout", &rpc_params).await
2710    }
2711
2712    /// Returns an object containing various wallet state info.
2713    async fn get_wallet_info(&self) -> Result<GetWalletInfoResponse, Self::Error> {
2714        self.call::<GetWalletInfoResponse>("getwalletinfo", &[]).await
2715    }
2716
2717    /// List all commands, or get help for a specified command.
2718    async fn help(&self, command: Option<String>) -> Result<HelpResponse, Self::Error> {
2719        let mut rpc_params = vec![];
2720        if let Some(val) = command {
2721            rpc_params.push(serde_json::json!(val));
2722        }
2723        self.call::<HelpResponse>("help", &rpc_params).await
2724    }
2725
2726    /// Import descriptors. This will trigger a rescan of the blockchain based on the earliest timestamp of all descriptors being imported. Requires a new wallet backup.
2727    /// When importing descriptors with multipath key expressions, if the multipath specifier contains exactly two elements, the descriptor produced from the second element will be imported as an internal descriptor.
2728    /// Note: This call can take over an hour to complete if using an early timestamp; during that time, other rpc calls
2729    /// may report that the imported keys, addresses or scripts exist but related transactions are still missing.
2730    /// The rescan is significantly faster if block filters are available (using startup option "-blockfilterindex=1").
2731    async fn import_descriptors(
2732        &self,
2733        requests: Vec<serde_json::Value>,
2734    ) -> Result<ImportDescriptorsResponse, Self::Error> {
2735        let mut rpc_params = vec![];
2736        rpc_params.push(serde_json::json!(requests));
2737        self.call::<ImportDescriptorsResponse>("importdescriptors", &rpc_params).await
2738    }
2739
2740    /// Import a mempool.dat file and attempt to add its contents to the mempool.
2741    /// Warning: Importing untrusted files is dangerous, especially if metadata from the file is taken over.
2742    async fn import_mempool(
2743        &self,
2744        filepath: String,
2745        options: Option<serde_json::Value>,
2746    ) -> Result<ImportMempoolResponse, Self::Error> {
2747        let mut rpc_params = vec![];
2748        rpc_params.push(serde_json::json!(filepath));
2749        if let Some(val) = options {
2750            rpc_params.push(serde_json::json!(val));
2751        }
2752        self.call::<ImportMempoolResponse>("importmempool", &rpc_params).await
2753    }
2754
2755    /// Imports funds without rescan. Corresponding address or script must previously be included in wallet. Aimed towards pruned wallets. The end-user is responsible to import additional transactions that subsequently spend the imported outputs or rescan after the point in the blockchain the transaction is included.
2756    async fn import_pruned_funds(
2757        &self,
2758        rawtransaction: String,
2759        txoutproof: String,
2760    ) -> Result<ImportPrunedFundsResponse, Self::Error> {
2761        let mut rpc_params = vec![];
2762        rpc_params.push(serde_json::json!(rawtransaction));
2763        rpc_params.push(serde_json::json!(txoutproof));
2764        self.call::<ImportPrunedFundsResponse>("importprunedfunds", &rpc_params).await
2765    }
2766
2767    /// Permanently marks a block as invalid, as if it violated a consensus rule.
2768    async fn invalidate_block(
2769        &self,
2770        blockhash: bitcoin::BlockHash,
2771    ) -> Result<InvalidateBlockResponse, Self::Error> {
2772        let mut rpc_params = vec![];
2773        rpc_params.push(serde_json::json!(blockhash));
2774        self.call::<InvalidateBlockResponse>("invalidateblock", &rpc_params).await
2775    }
2776
2777    /// Joins multiple distinct PSBTs with different inputs and outputs into one PSBT with inputs and outputs from all of the PSBTs
2778    /// No input in any of the PSBTs can be in more than one of the PSBTs.
2779    async fn join_psbts(
2780        &self,
2781        txs: Vec<serde_json::Value>,
2782    ) -> Result<JoinPsbtsResponse, Self::Error> {
2783        let mut rpc_params = vec![];
2784        rpc_params.push(serde_json::json!(txs));
2785        self.call::<JoinPsbtsResponse>("joinpsbts", &rpc_params).await
2786    }
2787
2788    /// Refills each descriptor keypool in the wallet up to the specified number of new keys.
2789    /// By default, descriptor wallets have 4 active ranged descriptors ("legacy", "p2sh-segwit", "bech32", "bech32m"), each with 1000 entries.
2790    /// Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.
2791    async fn keypool_refill(
2792        &self,
2793        newsize: Option<i64>,
2794    ) -> Result<KeypoolRefillResponse, Self::Error> {
2795        let mut rpc_params = vec![];
2796        if let Some(val) = newsize {
2797            rpc_params.push(serde_json::json!(val));
2798        }
2799        self.call::<KeypoolRefillResponse>("keypoolrefill", &rpc_params).await
2800    }
2801
2802    /// Lists groups of addresses which have had their common ownership
2803    /// made public by common use as inputs or as the resulting change
2804    /// in past transactions
2805    async fn list_address_groupings(&self) -> Result<ListAddressGroupingsResponse, Self::Error> {
2806        self.call::<ListAddressGroupingsResponse>("listaddressgroupings", &[]).await
2807    }
2808
2809    /// List all manually banned IPs/Subnets.
2810    async fn list_banned(&self) -> Result<ListBannedResponse, Self::Error> {
2811        self.call::<ListBannedResponse>("listbanned", &[]).await
2812    }
2813
2814    /// List all descriptors present in a wallet.
2815    async fn list_descriptors(
2816        &self,
2817        private: Option<bool>,
2818    ) -> Result<ListDescriptorsResponse, Self::Error> {
2819        let mut rpc_params = vec![];
2820        if let Some(val) = private {
2821            rpc_params.push(serde_json::json!(val));
2822        }
2823        self.call::<ListDescriptorsResponse>("listdescriptors", &rpc_params).await
2824    }
2825
2826    /// Returns the list of all labels, or labels that are assigned to addresses with a specific purpose.
2827    async fn list_labels(
2828        &self,
2829        purpose: Option<String>,
2830    ) -> Result<ListLabelsResponse, Self::Error> {
2831        let mut rpc_params = vec![];
2832        if let Some(val) = purpose {
2833            rpc_params.push(serde_json::json!(val));
2834        }
2835        self.call::<ListLabelsResponse>("listlabels", &rpc_params).await
2836    }
2837
2838    /// Returns list of temporarily unspendable outputs.
2839    /// See the lockunspent call to lock and unlock transactions for spending.
2840    async fn list_lock_unspent(&self) -> Result<ListLockUnspentResponse, Self::Error> {
2841        self.call::<ListLockUnspentResponse>("listlockunspent", &[]).await
2842    }
2843
2844    /// List balances by receiving address.
2845    async fn list_received_by_address(
2846        &self,
2847        minconf: Option<i64>,
2848        include_empty: Option<bool>,
2849        include_watchonly: Option<bool>,
2850        address_filter: Option<String>,
2851        include_immature_coinbase: Option<bool>,
2852    ) -> Result<ListReceivedByAddressResponse, Self::Error> {
2853        let mut rpc_params = vec![];
2854        if let Some(val) = minconf {
2855            rpc_params.push(serde_json::json!(val));
2856        }
2857        if let Some(val) = include_empty {
2858            rpc_params.push(serde_json::json!(val));
2859        }
2860        if let Some(val) = include_watchonly {
2861            rpc_params.push(serde_json::json!(val));
2862        }
2863        if let Some(val) = address_filter {
2864            rpc_params.push(serde_json::json!(val));
2865        }
2866        if let Some(val) = include_immature_coinbase {
2867            rpc_params.push(serde_json::json!(val));
2868        }
2869        self.call::<ListReceivedByAddressResponse>("listreceivedbyaddress", &rpc_params).await
2870    }
2871
2872    /// List received transactions by label.
2873    async fn list_received_by_label(
2874        &self,
2875        minconf: Option<i64>,
2876        include_empty: Option<bool>,
2877        include_watchonly: Option<bool>,
2878        include_immature_coinbase: Option<bool>,
2879    ) -> Result<ListReceivedByLabelResponse, Self::Error> {
2880        let mut rpc_params = vec![];
2881        if let Some(val) = minconf {
2882            rpc_params.push(serde_json::json!(val));
2883        }
2884        if let Some(val) = include_empty {
2885            rpc_params.push(serde_json::json!(val));
2886        }
2887        if let Some(val) = include_watchonly {
2888            rpc_params.push(serde_json::json!(val));
2889        }
2890        if let Some(val) = include_immature_coinbase {
2891            rpc_params.push(serde_json::json!(val));
2892        }
2893        self.call::<ListReceivedByLabelResponse>("listreceivedbylabel", &rpc_params).await
2894    }
2895
2896    /// Get all transactions in blocks since block \[blockhash\], or all transactions if omitted.
2897    /// If "blockhash" is no longer a part of the main chain, transactions from the fork point onward are included.
2898    /// Additionally, if include_removed is set, transactions affecting the wallet which were removed are returned in the "removed" array.
2899    async fn list_since_block(
2900        &self,
2901        blockhash: Option<bitcoin::BlockHash>,
2902        target_confirmations: Option<i64>,
2903        include_watchonly: Option<bool>,
2904        include_removed: Option<bool>,
2905        include_change: Option<bool>,
2906        label: Option<String>,
2907    ) -> Result<ListSinceBlockResponse, Self::Error> {
2908        let mut rpc_params = vec![];
2909        if let Some(val) = blockhash {
2910            rpc_params.push(serde_json::json!(val));
2911        }
2912        if let Some(val) = target_confirmations {
2913            rpc_params.push(serde_json::json!(val));
2914        }
2915        if let Some(val) = include_watchonly {
2916            rpc_params.push(serde_json::json!(val));
2917        }
2918        if let Some(val) = include_removed {
2919            rpc_params.push(serde_json::json!(val));
2920        }
2921        if let Some(val) = include_change {
2922            rpc_params.push(serde_json::json!(val));
2923        }
2924        if let Some(val) = label {
2925            rpc_params.push(serde_json::json!(val));
2926        }
2927        self.call::<ListSinceBlockResponse>("listsinceblock", &rpc_params).await
2928    }
2929
2930    /// If a label name is provided, this will return only incoming transactions paying to addresses with the specified label.
2931    /// Returns up to 'count' most recent transactions ordered from oldest to newest while skipping the first number of
2932    /// transactions specified in the 'skip' argument. A transaction can have multiple entries in this RPC response.
2933    /// For instance, a wallet transaction that pays three addresses — one wallet-owned and two external — will produce
2934    /// four entries. The payment to the wallet-owned address appears both as a send entry and as a receive entry.
2935    /// As a result, the RPC response will contain one entry in the receive category and three entries in the send category.
2936    async fn list_transactions(
2937        &self,
2938        label: Option<String>,
2939        count: Option<i64>,
2940        skip: Option<i64>,
2941        include_watchonly: Option<bool>,
2942    ) -> Result<ListTransactionsResponse, Self::Error> {
2943        let mut rpc_params = vec![];
2944        if let Some(val) = label {
2945            rpc_params.push(serde_json::json!(val));
2946        }
2947        if let Some(val) = count {
2948            rpc_params.push(serde_json::json!(val));
2949        }
2950        if let Some(val) = skip {
2951            rpc_params.push(serde_json::json!(val));
2952        }
2953        if let Some(val) = include_watchonly {
2954            rpc_params.push(serde_json::json!(val));
2955        }
2956        self.call::<ListTransactionsResponse>("listtransactions", &rpc_params).await
2957    }
2958
2959    /// Returns array of unspent transaction outputs
2960    /// with between minconf and maxconf (inclusive) confirmations.
2961    /// Optionally filter to only include txouts paid to specified addresses.
2962    async fn list_unspent(
2963        &self,
2964        minconf: Option<i64>,
2965        maxconf: Option<i64>,
2966        addresses: Option<Vec<serde_json::Value>>,
2967        include_unsafe: Option<bool>,
2968        query_options: Option<serde_json::Value>,
2969    ) -> Result<ListUnspentResponse, Self::Error> {
2970        let mut rpc_params = vec![];
2971        if let Some(val) = minconf {
2972            rpc_params.push(serde_json::json!(val));
2973        }
2974        if let Some(val) = maxconf {
2975            rpc_params.push(serde_json::json!(val));
2976        }
2977        if let Some(val) = addresses {
2978            rpc_params.push(serde_json::json!(val));
2979        }
2980        if let Some(val) = include_unsafe {
2981            rpc_params.push(serde_json::json!(val));
2982        }
2983        if let Some(val) = query_options {
2984            rpc_params.push(serde_json::json!(val));
2985        }
2986        self.call::<ListUnspentResponse>("listunspent", &rpc_params).await
2987    }
2988
2989    /// Returns a list of wallets in the wallet directory.
2990    async fn list_wallet_dir(&self) -> Result<ListWalletDirResponse, Self::Error> {
2991        self.call::<ListWalletDirResponse>("listwalletdir", &[]).await
2992    }
2993
2994    /// Returns a list of currently loaded wallets.
2995    /// For full information on the wallet, use "getwalletinfo"
2996    async fn list_wallets(&self) -> Result<ListWalletsResponse, Self::Error> {
2997        self.call::<ListWalletsResponse>("listwallets", &[]).await
2998    }
2999
3000    /// Load the serialized UTXO set from a file.
3001    /// Once this snapshot is loaded, its contents will be deserialized into a second chainstate data structure, which is then used to sync to the network's tip. Meanwhile, the original chainstate will complete the initial block download process in the background, eventually validating up to the block that the snapshot is based upon.
3002    /// The result is a usable bitcoind instance that is current with the network tip in a matter of minutes rather than hours. UTXO snapshot are typically obtained from third-party sources (HTTP, torrent, etc.) which is reasonable since their contents are always checked by hash.
3003    /// You can find more information on this process in the `assumeutxo` design document (<https://github.com/bitcoin/bitcoin/blob/master/doc/design/assumeutxo.md>).
3004    async fn load_txout_set(&self, path: String) -> Result<LoadTxoutSetResponse, Self::Error> {
3005        let mut rpc_params = vec![];
3006        rpc_params.push(serde_json::json!(path));
3007        self.call::<LoadTxoutSetResponse>("loadtxoutset", &rpc_params).await
3008    }
3009
3010    /// Loads a wallet from a wallet file or directory.
3011    /// Note that all wallet command-line options used when starting bitcoind will be
3012    /// applied to the new wallet.
3013    async fn load_wallet(
3014        &self,
3015        filename: String,
3016        load_on_startup: Option<bool>,
3017    ) -> Result<LoadWalletResponse, Self::Error> {
3018        let mut rpc_params = vec![];
3019        rpc_params.push(serde_json::json!(filename));
3020        if let Some(val) = load_on_startup {
3021            rpc_params.push(serde_json::json!(val));
3022        }
3023        self.call::<LoadWalletResponse>("loadwallet", &rpc_params).await
3024    }
3025
3026    /// Updates list of temporarily unspendable outputs.
3027    /// Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs.
3028    /// If no transaction outputs are specified when unlocking then all current locked transaction outputs are unlocked.
3029    /// A locked transaction output will not be chosen by automatic coin selection, when spending bitcoins.
3030    /// Manually selected coins are automatically unlocked.
3031    /// Locks are stored in memory only, unless persistent=true, in which case they will be written to the
3032    /// wallet database and loaded on node start. Unwritten (persistent=false) locks are always cleared
3033    /// (by virtue of process exit) when a node stops or fails. Unlocking will clear both persistent and not.
3034    /// Also see the listunspent call
3035    async fn lock_unspent(
3036        &self,
3037        unlock: bool,
3038        transactions: Option<Vec<serde_json::Value>>,
3039        persistent: Option<bool>,
3040    ) -> Result<LockUnspentResponse, Self::Error> {
3041        let mut rpc_params = vec![];
3042        rpc_params.push(serde_json::json!(unlock));
3043        if let Some(val) = transactions {
3044            rpc_params.push(serde_json::json!(val));
3045        }
3046        if let Some(val) = persistent {
3047            rpc_params.push(serde_json::json!(val));
3048        }
3049        self.call::<LockUnspentResponse>("lockunspent", &rpc_params).await
3050    }
3051
3052    /// Gets and sets the logging configuration.
3053    /// When called without an argument, returns the list of categories with status that are currently being debug logged or not.
3054    /// When called with arguments, adds or removes categories from debug logging and return the lists above.
3055    /// The arguments are evaluated in order "include", "exclude".
3056    /// If an item is both included and excluded, it will thus end up being excluded.
3057    /// The valid logging categories are: addrman, bench, blockstorage, cmpctblock, coindb, estimatefee, http, i2p, ipc, kernel, leveldb, libevent, mempool, mempoolrej, net, privatebroadcast, proxy, prune, qt, rand, reindex, rpc, scan, selectcoins, tor, txpackages, txreconciliation, validation, walletdb, zmq
3058    /// In addition, the following are available as category names with special meanings:
3059    /// - "all",  "1" : represent all logging categories.
3060    async fn logging(
3061        &self,
3062        include: Option<Vec<serde_json::Value>>,
3063        exclude: Option<Vec<serde_json::Value>>,
3064    ) -> Result<LoggingResponse, Self::Error> {
3065        let mut rpc_params = vec![];
3066        if let Some(val) = include {
3067            rpc_params.push(serde_json::json!(val));
3068        }
3069        if let Some(val) = exclude {
3070            rpc_params.push(serde_json::json!(val));
3071        }
3072        self.call::<LoggingResponse>("logging", &rpc_params).await
3073    }
3074
3075    /// Migrate the wallet to a descriptor wallet.
3076    /// A new wallet backup will need to be made.
3077    /// The migration process will create a backup of the wallet before migrating. This backup
3078    /// file will be named &lt;wallet name&gt;-&lt;timestamp&gt;.legacy.bak and can be found in the directory
3079    /// for this wallet. In the event of an incorrect migration, the backup can be restored using restorewallet.
3080    /// Encrypted wallets must have the passphrase provided as an argument to this call.
3081    /// This RPC may take a long time to complete. Increasing the RPC client timeout is recommended.
3082    async fn migrate_wallet(
3083        &self,
3084        wallet_name: Option<String>,
3085        passphrase: Option<String>,
3086    ) -> Result<MigrateWalletResponse, Self::Error> {
3087        let mut rpc_params = vec![];
3088        if let Some(val) = wallet_name {
3089            rpc_params.push(serde_json::json!(val));
3090        }
3091        if let Some(val) = passphrase {
3092            rpc_params.push(serde_json::json!(val));
3093        }
3094        self.call::<MigrateWalletResponse>("migratewallet", &rpc_params).await
3095    }
3096
3097    /// Bump the scheduler into the future (-regtest only)
3098    async fn mock_scheduler(&self, delta_time: i64) -> Result<MockSchedulerResponse, Self::Error> {
3099        let mut rpc_params = vec![];
3100        rpc_params.push(serde_json::json!(delta_time));
3101        self.call::<MockSchedulerResponse>("mockscheduler", &rpc_params).await
3102    }
3103
3104    /// Requests that a ping be sent to all other nodes, to measure ping time.
3105    /// Results are provided in getpeerinfo.
3106    /// Ping command is handled in queue with all other commands, so it measures processing backlog, not just network ping.
3107    async fn ping(&self) -> Result<PingResponse, Self::Error> {
3108        self.call::<PingResponse>("ping", &[]).await
3109    }
3110
3111    /// Treats a block as if it were received before others with the same work.
3112    /// A later preciousblock call can override the effect of an earlier one.
3113    /// The effects of preciousblock are not retained across restarts.
3114    async fn precious_block(
3115        &self,
3116        blockhash: bitcoin::BlockHash,
3117    ) -> Result<PreciousBlockResponse, Self::Error> {
3118        let mut rpc_params = vec![];
3119        rpc_params.push(serde_json::json!(blockhash));
3120        self.call::<PreciousBlockResponse>("preciousblock", &rpc_params).await
3121    }
3122
3123    /// Accepts the transaction into mined blocks at a higher (or lower) priority
3124    async fn prioritise_transaction(
3125        &self,
3126        txid: bitcoin::Txid,
3127        dummy: Option<i64>,
3128        fee_delta: i64,
3129    ) -> Result<PrioritiseTransactionResponse, Self::Error> {
3130        let mut rpc_params = vec![];
3131        rpc_params.push(serde_json::json!(txid));
3132        if let Some(val) = dummy {
3133            rpc_params.push(serde_json::json!(val));
3134        }
3135        rpc_params.push(serde_json::json!(fee_delta));
3136        self.call::<PrioritiseTransactionResponse>("prioritisetransaction", &rpc_params).await
3137    }
3138
3139    /// Attempts to delete block and undo data up to a specified height or timestamp, if eligible for pruning.
3140    /// Requires `-prune` to be enabled at startup. While pruned data may be re-fetched in some cases (e.g., via `getblockfrompeer`), local deletion is irreversible.
3141    async fn prune_blockchain(&self, height: i64) -> Result<PruneBlockchainResponse, Self::Error> {
3142        let mut rpc_params = vec![];
3143        rpc_params.push(serde_json::json!(height));
3144        self.call::<PruneBlockchainResponse>("pruneblockchain", &rpc_params).await
3145    }
3146
3147    /// Bumps the fee of a transaction T, replacing it with a new transaction B.
3148    /// Returns a PSBT instead of creating and signing a new transaction.
3149    /// A transaction with the given txid must be in the wallet.
3150    /// The command will pay the additional fee by reducing change outputs or adding inputs when necessary.
3151    /// It may add a new change output if one does not already exist.
3152    /// All inputs in the original transaction will be included in the replacement transaction.
3153    /// The command will fail if the wallet or mempool contains a transaction that spends one of T's outputs.
3154    /// By default, the new fee will be calculated automatically using the estimatesmartfee RPC.
3155    /// The user can specify a confirmation target for estimatesmartfee.
3156    /// Alternatively, the user can specify a fee rate in sat/vB for the new transaction.
3157    /// At a minimum, the new fee rate must be high enough to pay an additional new relay fee (incrementalfee
3158    /// returned by getnetworkinfo) to enter the node's mempool.
3159    /// * WARNING: before version 0.21, fee_rate was in BTC/kvB. As of 0.21, fee_rate is in sat/vB. *
3160    async fn psbt_bump_fee(
3161        &self,
3162        txid: bitcoin::Txid,
3163        options: Option<serde_json::Value>,
3164    ) -> Result<PsbtBumpFeeResponse, Self::Error> {
3165        let mut rpc_params = vec![];
3166        rpc_params.push(serde_json::json!(txid));
3167        if let Some(val) = options {
3168            rpc_params.push(serde_json::json!(val));
3169        }
3170        self.call::<PsbtBumpFeeResponse>("psbtbumpfee", &rpc_params).await
3171    }
3172
3173    /// Removes invalidity status of a block, its ancestors and its descendants, reconsider them for activation.
3174    /// This can be used to undo the effects of invalidateblock.
3175    async fn reconsider_block(
3176        &self,
3177        blockhash: bitcoin::BlockHash,
3178    ) -> Result<ReconsiderBlockResponse, Self::Error> {
3179        let mut rpc_params = vec![];
3180        rpc_params.push(serde_json::json!(blockhash));
3181        self.call::<ReconsiderBlockResponse>("reconsiderblock", &rpc_params).await
3182    }
3183
3184    /// Deletes the specified transaction from the wallet. Meant for use with pruned wallets and as a companion to importprunedfunds. This will affect wallet balances.
3185    async fn remove_pruned_funds(
3186        &self,
3187        txid: bitcoin::Txid,
3188    ) -> Result<RemovePrunedFundsResponse, Self::Error> {
3189        let mut rpc_params = vec![];
3190        rpc_params.push(serde_json::json!(txid));
3191        self.call::<RemovePrunedFundsResponse>("removeprunedfunds", &rpc_params).await
3192    }
3193
3194    /// Rescan the local blockchain for wallet related transactions.
3195    /// Note: Use "getwalletinfo" to query the scanning progress.
3196    /// The rescan is significantly faster if block filters are available
3197    /// (using startup option "-blockfilterindex=1").
3198    async fn rescan_blockchain(
3199        &self,
3200        start_height: Option<i64>,
3201        stop_height: Option<i64>,
3202    ) -> Result<RescanBlockchainResponse, Self::Error> {
3203        let mut rpc_params = vec![];
3204        if let Some(val) = start_height {
3205            rpc_params.push(serde_json::json!(val));
3206        }
3207        if let Some(val) = stop_height {
3208            rpc_params.push(serde_json::json!(val));
3209        }
3210        self.call::<RescanBlockchainResponse>("rescanblockchain", &rpc_params).await
3211    }
3212
3213    /// Restores and loads a wallet from backup.
3214    /// The rescan is significantly faster if block filters are available
3215    /// (using startup option "-blockfilterindex=1").
3216    async fn restore_wallet(
3217        &self,
3218        wallet_name: String,
3219        backup_file: String,
3220        load_on_startup: Option<bool>,
3221    ) -> Result<RestoreWalletResponse, Self::Error> {
3222        let mut rpc_params = vec![];
3223        rpc_params.push(serde_json::json!(wallet_name));
3224        rpc_params.push(serde_json::json!(backup_file));
3225        if let Some(val) = load_on_startup {
3226            rpc_params.push(serde_json::json!(val));
3227        }
3228        self.call::<RestoreWalletResponse>("restorewallet", &rpc_params).await
3229    }
3230
3231    /// Dumps the mempool to disk. It will fail until the previous dump is fully loaded.
3232    async fn save_mempool(&self) -> Result<SaveMempoolResponse, Self::Error> {
3233        self.call::<SaveMempoolResponse>("savemempool", &[]).await
3234    }
3235
3236    /// Return relevant blockhashes for given descriptors (requires blockfilterindex).
3237    /// This call may take several minutes. Make sure to use no RPC timeout (bitcoin-cli -rpcclienttimeout=0)
3238    async fn scan_blocks(
3239        &self,
3240        action: String,
3241        scanobjects: Option<Vec<serde_json::Value>>,
3242        start_height: Option<i64>,
3243        stop_height: Option<i64>,
3244        filtertype: Option<String>,
3245        options: Option<serde_json::Value>,
3246    ) -> Result<ScanBlocksResponse, Self::Error> {
3247        let mut rpc_params = vec![];
3248        rpc_params.push(serde_json::json!(action));
3249        if let Some(val) = scanobjects {
3250            rpc_params.push(serde_json::json!(val));
3251        }
3252        if let Some(val) = start_height {
3253            rpc_params.push(serde_json::json!(val));
3254        }
3255        if let Some(val) = stop_height {
3256            rpc_params.push(serde_json::json!(val));
3257        }
3258        if let Some(val) = filtertype {
3259            rpc_params.push(serde_json::json!(val));
3260        }
3261        if let Some(val) = options {
3262            rpc_params.push(serde_json::json!(val));
3263        }
3264        self.call::<ScanBlocksResponse>("scanblocks", &rpc_params).await
3265    }
3266
3267    /// Scans the unspent transaction output set for entries that match certain output descriptors.
3268    /// Examples of output descriptors are:
3269    /// addr(&lt;address&gt;)                      Outputs whose output script corresponds to the specified address (does not include P2PK)
3270    /// raw(&lt;hex script&gt;)                    Outputs whose output script equals the specified hex-encoded bytes
3271    /// combo(&lt;pubkey&gt;)                      P2PK, P2PKH, P2WPKH, and P2SH-P2WPKH outputs for the given pubkey
3272    /// pkh(&lt;pubkey&gt;)                        P2PKH outputs for the given pubkey
3273    /// sh(multi(&lt;n&gt;,&lt;pubkey&gt;,&lt;pubkey&gt;,...)) P2SH-multisig outputs for the given threshold and pubkeys
3274    /// tr(&lt;pubkey&gt;)                         P2TR
3275    /// tr(&lt;pubkey&gt;,{pk(&lt;pubkey&gt;)})          P2TR with single fallback pubkey in tapscript
3276    /// rawtr(&lt;pubkey&gt;)                      P2TR with the specified key as output key rather than inner
3277    /// wsh(and_v(v:pk(&lt;pubkey&gt;),after(2)))  P2WSH miniscript with mandatory pubkey and a timelock
3278    /// In the above, &lt;pubkey&gt; either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one
3279    /// or more path elements separated by "/", and optionally ending in "/*" (unhardened), or "/*'" or "/*h" (hardened) to specify all
3280    /// unhardened or hardened child keys.
3281    /// In the latter case, a range needs to be specified by below if different from 1000.
3282    /// For more information on output descriptors, see the documentation in the doc/descriptors.md file.
3283    async fn scan_txout_set(
3284        &self,
3285        action: String,
3286        scanobjects: Option<Vec<serde_json::Value>>,
3287    ) -> Result<ScanTxoutSetResponse, Self::Error> {
3288        let mut rpc_params = vec![];
3289        rpc_params.push(serde_json::json!(action));
3290        if let Some(val) = scanobjects {
3291            rpc_params.push(serde_json::json!(val));
3292        }
3293        self.call::<ScanTxoutSetResponse>("scantxoutset", &rpc_params).await
3294    }
3295
3296    /// Return RPC command JSON Schema descriptions.
3297    async fn schema(&self) -> Result<SchemaResponse, Self::Error> {
3298        self.call::<SchemaResponse>("schema", &[]).await
3299    }
3300
3301    /// EXPERIMENTAL warning: this call may be changed in future releases.
3302    /// Send a transaction.
3303    async fn send(
3304        &self,
3305        outputs: Vec<serde_json::Value>,
3306        conf_target: Option<i64>,
3307        estimate_mode: Option<String>,
3308        fee_rate: Option<serde_json::Value>,
3309        options: Option<serde_json::Value>,
3310        version: Option<i64>,
3311    ) -> Result<SendResponse, Self::Error> {
3312        let mut rpc_params = vec![];
3313        rpc_params.push(serde_json::json!(outputs));
3314        if let Some(val) = conf_target {
3315            rpc_params.push(serde_json::json!(val));
3316        }
3317        if let Some(val) = estimate_mode {
3318            rpc_params.push(serde_json::json!(val));
3319        }
3320        if let Some(val) = fee_rate {
3321            rpc_params.push(serde_json::json!(val));
3322        }
3323        if let Some(val) = options {
3324            rpc_params.push(serde_json::json!(val));
3325        }
3326        if let Some(val) = version {
3327            rpc_params.push(serde_json::json!(val));
3328        }
3329        self.call::<SendResponse>("send", &rpc_params).await
3330    }
3331
3332    /// EXPERIMENTAL warning: this call may be changed in future releases.
3333    /// Spend the value of all (or specific) confirmed UTXOs and unconfirmed change in the wallet to one or more recipients.
3334    /// Unconfirmed inbound UTXOs and locked UTXOs will not be spent. Sendall will respect the avoid_reuse wallet flag.
3335    /// If your wallet contains many small inputs, either because it received tiny payments or as a result of accumulating change, consider using `send_max` to exclude inputs that are worth less than the fees needed to spend them.
3336    async fn send_all(
3337        &self,
3338        recipients: Vec<serde_json::Value>,
3339        conf_target: Option<i64>,
3340        estimate_mode: Option<String>,
3341        fee_rate: Option<serde_json::Value>,
3342        options: Option<serde_json::Value>,
3343    ) -> Result<SendAllResponse, Self::Error> {
3344        let mut rpc_params = vec![];
3345        rpc_params.push(serde_json::json!(recipients));
3346        if let Some(val) = conf_target {
3347            rpc_params.push(serde_json::json!(val));
3348        }
3349        if let Some(val) = estimate_mode {
3350            rpc_params.push(serde_json::json!(val));
3351        }
3352        if let Some(val) = fee_rate {
3353            rpc_params.push(serde_json::json!(val));
3354        }
3355        if let Some(val) = options {
3356            rpc_params.push(serde_json::json!(val));
3357        }
3358        self.call::<SendAllResponse>("sendall", &rpc_params).await
3359    }
3360
3361    /// Send multiple times. Amounts are double-precision floating point numbers.
3362    /// Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.
3363    async fn send_many(
3364        &self,
3365        dummy: Option<String>,
3366        amounts: serde_json::Value,
3367        minconf: Option<i64>,
3368        comment: Option<String>,
3369        subtractfeefrom: Option<Vec<serde_json::Value>>,
3370        replaceable: Option<bool>,
3371        conf_target: Option<i64>,
3372        estimate_mode: Option<String>,
3373        fee_rate: Option<serde_json::Value>,
3374        verbose: Option<bool>,
3375    ) -> Result<SendManyResponse, Self::Error> {
3376        let mut rpc_params = vec![];
3377        if let Some(val) = dummy {
3378            rpc_params.push(serde_json::json!(val));
3379        }
3380        rpc_params.push(serde_json::json!(amounts));
3381        if let Some(val) = minconf {
3382            rpc_params.push(serde_json::json!(val));
3383        }
3384        if let Some(val) = comment {
3385            rpc_params.push(serde_json::json!(val));
3386        }
3387        if let Some(val) = subtractfeefrom {
3388            rpc_params.push(serde_json::json!(val));
3389        }
3390        if let Some(val) = replaceable {
3391            rpc_params.push(serde_json::json!(val));
3392        }
3393        if let Some(val) = conf_target {
3394            rpc_params.push(serde_json::json!(val));
3395        }
3396        if let Some(val) = estimate_mode {
3397            rpc_params.push(serde_json::json!(val));
3398        }
3399        if let Some(val) = fee_rate {
3400            rpc_params.push(serde_json::json!(val));
3401        }
3402        if let Some(val) = verbose {
3403            rpc_params.push(serde_json::json!(val));
3404        }
3405        self.call::<SendManyResponse>("sendmany", &rpc_params).await
3406    }
3407
3408    /// Send a p2p message to a peer specified by id.
3409    /// The message type and body must be provided, the message header will be generated.
3410    /// This RPC is for testing only.
3411    async fn send_msg_to_peer(
3412        &self,
3413        peer_id: i64,
3414        msg_type: String,
3415        msg: String,
3416    ) -> Result<SendMsgToPeerResponse, Self::Error> {
3417        let mut rpc_params = vec![];
3418        rpc_params.push(serde_json::json!(peer_id));
3419        rpc_params.push(serde_json::json!(msg_type));
3420        rpc_params.push(serde_json::json!(msg));
3421        self.call::<SendMsgToPeerResponse>("sendmsgtopeer", &rpc_params).await
3422    }
3423
3424    /// Submit a raw transaction (serialized, hex-encoded) to the network.
3425    /// If -privatebroadcast is disabled, then the transaction will be put into the
3426    /// local mempool of the node and will be sent unconditionally to all currently
3427    /// connected peers, so using sendrawtransaction for manual rebroadcast will degrade
3428    /// privacy by leaking the transaction's origin, as nodes will normally not
3429    /// rebroadcast non-wallet transactions already in their mempool.
3430    /// If -privatebroadcast is enabled, then the transaction will be sent only via
3431    /// dedicated, short-lived connections to Tor or I2P peers or IPv4/IPv6 peers
3432    /// via the Tor network. This conceals the transaction's origin. The transaction
3433    /// will only enter the local mempool when it is received back from the network.
3434    /// A specific exception, RPC_TRANSACTION_ALREADY_IN_UTXO_SET, may throw if the transaction cannot be added to the mempool.
3435    /// Related RPCs: createrawtransaction, signrawtransactionwithkey
3436    async fn send_raw_transaction(
3437        &self,
3438        hexstring: String,
3439        maxfeerate: Option<serde_json::Value>,
3440        maxburnamount: Option<serde_json::Value>,
3441    ) -> Result<SendRawTransactionResponse, Self::Error> {
3442        let mut rpc_params = vec![];
3443        rpc_params.push(serde_json::json!(hexstring));
3444        if let Some(val) = maxfeerate {
3445            rpc_params.push(serde_json::json!(val));
3446        }
3447        if let Some(val) = maxburnamount {
3448            rpc_params.push(serde_json::json!(val));
3449        }
3450        self.call::<SendRawTransactionResponse>("sendrawtransaction", &rpc_params).await
3451    }
3452
3453    /// Send an amount to a given address.
3454    /// Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.
3455    async fn send_to_address(
3456        &self,
3457        address: bitcoin::Address,
3458        amount: serde_json::Value,
3459        comment: Option<String>,
3460        comment_to: Option<String>,
3461        subtractfeefromamount: Option<bool>,
3462        replaceable: Option<bool>,
3463        conf_target: Option<i64>,
3464        estimate_mode: Option<String>,
3465        avoid_reuse: Option<bool>,
3466        fee_rate: Option<serde_json::Value>,
3467        verbose: Option<bool>,
3468    ) -> Result<SendToAddressResponse, Self::Error> {
3469        let mut rpc_params = vec![];
3470        rpc_params.push(serde_json::json!(address));
3471        rpc_params.push(serde_json::json!(amount));
3472        if let Some(val) = comment {
3473            rpc_params.push(serde_json::json!(val));
3474        }
3475        if let Some(val) = comment_to {
3476            rpc_params.push(serde_json::json!(val));
3477        }
3478        if let Some(val) = subtractfeefromamount {
3479            rpc_params.push(serde_json::json!(val));
3480        }
3481        if let Some(val) = replaceable {
3482            rpc_params.push(serde_json::json!(val));
3483        }
3484        if let Some(val) = conf_target {
3485            rpc_params.push(serde_json::json!(val));
3486        }
3487        if let Some(val) = estimate_mode {
3488            rpc_params.push(serde_json::json!(val));
3489        }
3490        if let Some(val) = avoid_reuse {
3491            rpc_params.push(serde_json::json!(val));
3492        }
3493        if let Some(val) = fee_rate {
3494            rpc_params.push(serde_json::json!(val));
3495        }
3496        if let Some(val) = verbose {
3497            rpc_params.push(serde_json::json!(val));
3498        }
3499        self.call::<SendToAddressResponse>("sendtoaddress", &rpc_params).await
3500    }
3501
3502    /// Attempts to add or remove an IP/Subnet from the banned list.
3503    async fn set_ban(
3504        &self,
3505        subnet: String,
3506        command: String,
3507        bantime: Option<i64>,
3508        absolute: Option<bool>,
3509    ) -> Result<SetBanResponse, Self::Error> {
3510        let mut rpc_params = vec![];
3511        rpc_params.push(serde_json::json!(subnet));
3512        rpc_params.push(serde_json::json!(command));
3513        if let Some(val) = bantime {
3514            rpc_params.push(serde_json::json!(val));
3515        }
3516        if let Some(val) = absolute {
3517            rpc_params.push(serde_json::json!(val));
3518        }
3519        self.call::<SetBanResponse>("setban", &rpc_params).await
3520    }
3521
3522    /// Sets the label associated with the given address.
3523    async fn set_label(
3524        &self,
3525        address: bitcoin::Address,
3526        label: String,
3527    ) -> Result<SetLabelResponse, Self::Error> {
3528        let mut rpc_params = vec![];
3529        rpc_params.push(serde_json::json!(address));
3530        rpc_params.push(serde_json::json!(label));
3531        self.call::<SetLabelResponse>("setlabel", &rpc_params).await
3532    }
3533
3534    /// Set the local time to given timestamp (-regtest only)
3535    async fn set_mock_time(&self, timestamp: i64) -> Result<SetMockTimeResponse, Self::Error> {
3536        let mut rpc_params = vec![];
3537        rpc_params.push(serde_json::json!(timestamp));
3538        self.call::<SetMockTimeResponse>("setmocktime", &rpc_params).await
3539    }
3540
3541    /// Disable/enable all p2p network activity.
3542    async fn set_network_active(
3543        &self,
3544        state: bool,
3545    ) -> Result<SetNetworkActiveResponse, Self::Error> {
3546        let mut rpc_params = vec![];
3547        rpc_params.push(serde_json::json!(state));
3548        self.call::<SetNetworkActiveResponse>("setnetworkactive", &rpc_params).await
3549    }
3550
3551    /// (DEPRECATED) Set the transaction fee rate in BTC/kvB for this wallet. Overrides the global -paytxfee command line parameter.
3552    /// Can be deactivated by passing 0 as the fee. In that case automatic fee selection will be used by default.
3553    async fn set_tx_fee(&self, amount: serde_json::Value) -> Result<SetTxFeeResponse, Self::Error> {
3554        let mut rpc_params = vec![];
3555        rpc_params.push(serde_json::json!(amount));
3556        self.call::<SetTxFeeResponse>("settxfee", &rpc_params).await
3557    }
3558
3559    /// Change the state of the given wallet flag for a wallet.
3560    async fn set_wallet_flag(
3561        &self,
3562        flag: String,
3563        value: Option<bool>,
3564    ) -> Result<SetWalletFlagResponse, Self::Error> {
3565        let mut rpc_params = vec![];
3566        rpc_params.push(serde_json::json!(flag));
3567        if let Some(val) = value {
3568            rpc_params.push(serde_json::json!(val));
3569        }
3570        self.call::<SetWalletFlagResponse>("setwalletflag", &rpc_params).await
3571    }
3572
3573    /// Sign a message with the private key of an address
3574    /// Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.
3575    async fn sign_message(
3576        &self,
3577        address: bitcoin::Address,
3578        message: String,
3579    ) -> Result<SignMessageResponse, Self::Error> {
3580        let mut rpc_params = vec![];
3581        rpc_params.push(serde_json::json!(address));
3582        rpc_params.push(serde_json::json!(message));
3583        self.call::<SignMessageResponse>("signmessage", &rpc_params).await
3584    }
3585
3586    /// Sign a message with the private key of an address
3587    async fn sign_message_with_priv_key(
3588        &self,
3589        privkey: String,
3590        message: String,
3591    ) -> Result<SignMessageWithPrivKeyResponse, Self::Error> {
3592        let mut rpc_params = vec![];
3593        rpc_params.push(serde_json::json!(privkey));
3594        rpc_params.push(serde_json::json!(message));
3595        self.call::<SignMessageWithPrivKeyResponse>("signmessagewithprivkey", &rpc_params).await
3596    }
3597
3598    /// Sign inputs for raw transaction (serialized, hex-encoded).
3599    /// The second argument is an array of base58-encoded private
3600    /// keys that will be the only keys used to sign the transaction.
3601    /// The third optional argument (may be null) is an array of previous transaction outputs that
3602    /// this transaction depends on but may not yet be in the block chain.
3603    async fn sign_raw_transaction_with_key(
3604        &self,
3605        hexstring: String,
3606        privkeys: Vec<serde_json::Value>,
3607        prevtxs: Option<Vec<serde_json::Value>>,
3608        sighashtype: Option<String>,
3609    ) -> Result<SignRawTransactionWithKeyResponse, Self::Error> {
3610        let mut rpc_params = vec![];
3611        rpc_params.push(serde_json::json!(hexstring));
3612        rpc_params.push(serde_json::json!(privkeys));
3613        if let Some(val) = prevtxs {
3614            rpc_params.push(serde_json::json!(val));
3615        }
3616        if let Some(val) = sighashtype {
3617            rpc_params.push(serde_json::json!(val));
3618        }
3619        self.call::<SignRawTransactionWithKeyResponse>("signrawtransactionwithkey", &rpc_params)
3620            .await
3621    }
3622
3623    /// Sign inputs for raw transaction (serialized, hex-encoded).
3624    /// The second optional argument (may be null) is an array of previous transaction outputs that
3625    /// this transaction depends on but may not yet be in the block chain.
3626    /// Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.
3627    async fn sign_raw_transaction_with_wallet(
3628        &self,
3629        hexstring: String,
3630        prevtxs: Option<Vec<serde_json::Value>>,
3631        sighashtype: Option<String>,
3632    ) -> Result<SignRawTransactionWithWalletResponse, Self::Error> {
3633        let mut rpc_params = vec![];
3634        rpc_params.push(serde_json::json!(hexstring));
3635        if let Some(val) = prevtxs {
3636            rpc_params.push(serde_json::json!(val));
3637        }
3638        if let Some(val) = sighashtype {
3639            rpc_params.push(serde_json::json!(val));
3640        }
3641        self.call::<SignRawTransactionWithWalletResponse>(
3642            "signrawtransactionwithwallet",
3643            &rpc_params,
3644        )
3645        .await
3646    }
3647
3648    /// Calculate the balance change resulting in the signing and broadcasting of the given transaction(s).
3649    async fn simulate_raw_transaction(
3650        &self,
3651        rawtxs: Option<Vec<serde_json::Value>>,
3652        options: Option<serde_json::Value>,
3653    ) -> Result<SimulateRawTransactionResponse, Self::Error> {
3654        let mut rpc_params = vec![];
3655        if let Some(val) = rawtxs {
3656            rpc_params.push(serde_json::json!(val));
3657        }
3658        if let Some(val) = options {
3659            rpc_params.push(serde_json::json!(val));
3660        }
3661        self.call::<SimulateRawTransactionResponse>("simulaterawtransaction", &rpc_params).await
3662    }
3663
3664    /// Request a graceful shutdown of Bitcoin Core.
3665    async fn stop(&self, wait: Option<i64>) -> Result<StopResponse, Self::Error> {
3666        let mut rpc_params = vec![];
3667        if let Some(val) = wait {
3668            rpc_params.push(serde_json::json!(val));
3669        }
3670        self.call::<StopResponse>("stop", &rpc_params).await
3671    }
3672
3673    /// Attempts to submit new block to network.
3674    /// See <https://en.bitcoin.it/wiki/BIP_0022> for full specification.
3675    async fn submit_block(
3676        &self,
3677        hexdata: String,
3678        dummy: Option<String>,
3679    ) -> Result<SubmitBlockResponse, Self::Error> {
3680        let mut rpc_params = vec![];
3681        rpc_params.push(serde_json::json!(hexdata));
3682        if let Some(val) = dummy {
3683            rpc_params.push(serde_json::json!(val));
3684        }
3685        self.call::<SubmitBlockResponse>("submitblock", &rpc_params).await
3686    }
3687
3688    /// Decode the given hexdata as a header and submit it as a candidate chain tip if valid.
3689    /// Throws when the header is invalid.
3690    async fn submit_header(&self, hexdata: String) -> Result<SubmitHeaderResponse, Self::Error> {
3691        let mut rpc_params = vec![];
3692        rpc_params.push(serde_json::json!(hexdata));
3693        self.call::<SubmitHeaderResponse>("submitheader", &rpc_params).await
3694    }
3695
3696    /// Submit a package of raw transactions (serialized, hex-encoded) to local node.
3697    /// The package will be validated according to consensus and mempool policy rules. If any transaction passes, it will be accepted to mempool.
3698    /// This RPC is experimental and the interface may be unstable. Refer to doc/policy/packages.md for documentation on package policies.
3699    /// Warning: successful submission does not mean the transactions will propagate throughout the network.
3700    async fn submit_package(
3701        &self,
3702        package: Vec<serde_json::Value>,
3703        maxfeerate: Option<serde_json::Value>,
3704        maxburnamount: Option<serde_json::Value>,
3705    ) -> Result<SubmitPackageResponse, Self::Error> {
3706        let mut rpc_params = vec![];
3707        rpc_params.push(serde_json::json!(package));
3708        if let Some(val) = maxfeerate {
3709            rpc_params.push(serde_json::json!(val));
3710        }
3711        if let Some(val) = maxburnamount {
3712            rpc_params.push(serde_json::json!(val));
3713        }
3714        self.call::<SubmitPackageResponse>("submitpackage", &rpc_params).await
3715    }
3716
3717    /// Waits for the validation interface queue to catch up on everything that was there when we entered this function.
3718    async fn sync_with_validation_interface_queue(
3719        &self,
3720    ) -> Result<SyncWithValidationInterfaceQueueResponse, Self::Error> {
3721        self.call::<SyncWithValidationInterfaceQueueResponse>(
3722            "syncwithvalidationinterfacequeue",
3723            &[],
3724        )
3725        .await
3726    }
3727
3728    /// Returns result of mempool acceptance tests indicating if raw transaction(s) (serialized, hex-encoded) would be accepted by mempool.
3729    /// If multiple transactions are passed in, parents must come before children and package policies apply: the transactions cannot conflict with any mempool transactions or each other.
3730    /// If one transaction fails, other transactions may not be fully validated (the 'allowed' key will be blank).
3731    /// The maximum number of transactions allowed is 25.
3732    /// This checks if transactions violate the consensus or policy rules.
3733    /// See sendrawtransaction call.
3734    async fn test_mempool_accept(
3735        &self,
3736        rawtxs: Vec<serde_json::Value>,
3737        maxfeerate: Option<serde_json::Value>,
3738    ) -> Result<TestMempoolAcceptResponse, Self::Error> {
3739        let mut rpc_params = vec![];
3740        rpc_params.push(serde_json::json!(rawtxs));
3741        if let Some(val) = maxfeerate {
3742            rpc_params.push(serde_json::json!(val));
3743        }
3744        self.call::<TestMempoolAcceptResponse>("testmempoolaccept", &rpc_params).await
3745    }
3746
3747    /// Unloads the wallet referenced by the request endpoint or the wallet_name argument.
3748    /// If both are specified, they must be identical.
3749    async fn unload_wallet(
3750        &self,
3751        wallet_name: Option<String>,
3752        load_on_startup: Option<bool>,
3753    ) -> Result<UnloadWalletResponse, Self::Error> {
3754        let mut rpc_params = vec![];
3755        if let Some(val) = wallet_name {
3756            rpc_params.push(serde_json::json!(val));
3757        }
3758        if let Some(val) = load_on_startup {
3759            rpc_params.push(serde_json::json!(val));
3760        }
3761        self.call::<UnloadWalletResponse>("unloadwallet", &rpc_params).await
3762    }
3763
3764    /// Returns the total uptime of the server.
3765    async fn uptime(&self) -> Result<UptimeResponse, Self::Error> {
3766        self.call::<UptimeResponse>("uptime", &[]).await
3767    }
3768
3769    /// Updates all segwit inputs and outputs in a PSBT with data from output descriptors, the UTXO set, txindex, or the mempool.
3770    async fn utxo_update_psbt(
3771        &self,
3772        psbt: String,
3773        descriptors: Option<Vec<serde_json::Value>>,
3774    ) -> Result<UtxoUpdatePsbtResponse, Self::Error> {
3775        let mut rpc_params = vec![];
3776        rpc_params.push(serde_json::json!(psbt));
3777        if let Some(val) = descriptors {
3778            rpc_params.push(serde_json::json!(val));
3779        }
3780        self.call::<UtxoUpdatePsbtResponse>("utxoupdatepsbt", &rpc_params).await
3781    }
3782
3783    /// Return information about the given bitcoin address.
3784    async fn validate_address(
3785        &self,
3786        address: bitcoin::Address,
3787    ) -> Result<ValidateAddressResponse, Self::Error> {
3788        let mut rpc_params = vec![];
3789        rpc_params.push(serde_json::json!(address));
3790        self.call::<ValidateAddressResponse>("validateaddress", &rpc_params).await
3791    }
3792
3793    /// Verifies blockchain database.
3794    async fn verify_chain(
3795        &self,
3796        checklevel: Option<i64>,
3797        nblocks: Option<i64>,
3798    ) -> Result<VerifyChainResponse, Self::Error> {
3799        let mut rpc_params = vec![];
3800        if let Some(val) = checklevel {
3801            rpc_params.push(serde_json::json!(val));
3802        }
3803        if let Some(val) = nblocks {
3804            rpc_params.push(serde_json::json!(val));
3805        }
3806        self.call::<VerifyChainResponse>("verifychain", &rpc_params).await
3807    }
3808
3809    /// Verify a signed message.
3810    async fn verify_message(
3811        &self,
3812        address: bitcoin::Address,
3813        signature: String,
3814        message: String,
3815    ) -> Result<VerifyMessageResponse, Self::Error> {
3816        let mut rpc_params = vec![];
3817        rpc_params.push(serde_json::json!(address));
3818        rpc_params.push(serde_json::json!(signature));
3819        rpc_params.push(serde_json::json!(message));
3820        self.call::<VerifyMessageResponse>("verifymessage", &rpc_params).await
3821    }
3822
3823    /// Verifies that a proof points to a transaction in a block, returning the transaction it commits to
3824    /// and throwing an RPC error if the block is not in our best chain
3825    async fn verify_txout_proof(
3826        &self,
3827        proof: String,
3828    ) -> Result<VerifyTxoutProofResponse, Self::Error> {
3829        let mut rpc_params = vec![];
3830        rpc_params.push(serde_json::json!(proof));
3831        self.call::<VerifyTxoutProofResponse>("verifytxoutproof", &rpc_params).await
3832    }
3833
3834    /// Waits for a specific new block and returns useful info about it.
3835    /// Returns the current block on timeout or exit.
3836    /// Make sure to use no RPC timeout (bitcoin-cli -rpcclienttimeout=0)
3837    async fn wait_for_block(
3838        &self,
3839        blockhash: bitcoin::BlockHash,
3840        timeout: Option<i64>,
3841    ) -> Result<WaitForBlockResponse, Self::Error> {
3842        let mut rpc_params = vec![];
3843        rpc_params.push(serde_json::json!(blockhash));
3844        if let Some(val) = timeout {
3845            rpc_params.push(serde_json::json!(val));
3846        }
3847        self.call::<WaitForBlockResponse>("waitforblock", &rpc_params).await
3848    }
3849
3850    /// Waits for (at least) block height and returns the height and hash
3851    /// of the current tip.
3852    /// Returns the current block on timeout or exit.
3853    /// Make sure to use no RPC timeout (bitcoin-cli -rpcclienttimeout=0)
3854    async fn wait_for_block_height(
3855        &self,
3856        height: i64,
3857        timeout: Option<i64>,
3858    ) -> Result<WaitForBlockHeightResponse, Self::Error> {
3859        let mut rpc_params = vec![];
3860        rpc_params.push(serde_json::json!(height));
3861        if let Some(val) = timeout {
3862            rpc_params.push(serde_json::json!(val));
3863        }
3864        self.call::<WaitForBlockHeightResponse>("waitforblockheight", &rpc_params).await
3865    }
3866
3867    /// Waits for any new block and returns useful info about it.
3868    /// Returns the current block on timeout or exit.
3869    /// Make sure to use no RPC timeout (bitcoin-cli -rpcclienttimeout=0)
3870    async fn wait_for_new_block(
3871        &self,
3872        timeout: Option<i64>,
3873        current_tip: Option<String>,
3874    ) -> Result<WaitForNewBlockResponse, Self::Error> {
3875        let mut rpc_params = vec![];
3876        if let Some(val) = timeout {
3877            rpc_params.push(serde_json::json!(val));
3878        }
3879        if let Some(val) = current_tip {
3880            rpc_params.push(serde_json::json!(val));
3881        }
3882        self.call::<WaitForNewBlockResponse>("waitfornewblock", &rpc_params).await
3883    }
3884
3885    /// Creates and funds a transaction in the Partially Signed Transaction format.
3886    /// Implements the Creator and Updater roles.
3887    /// All existing inputs must either have their previous output transaction be in the wallet
3888    /// or be in the UTXO set. Solving data must be provided for non-wallet inputs.
3889    async fn wallet_create_funded_psbt(
3890        &self,
3891        inputs: Option<Vec<serde_json::Value>>,
3892        outputs: Vec<serde_json::Value>,
3893        locktime: Option<i64>,
3894        options: Option<serde_json::Value>,
3895        bip32derivs: Option<bool>,
3896        version: Option<i64>,
3897    ) -> Result<WalletCreateFundedPsbtResponse, Self::Error> {
3898        let mut rpc_params = vec![];
3899        if let Some(val) = inputs {
3900            rpc_params.push(serde_json::json!(val));
3901        }
3902        rpc_params.push(serde_json::json!(outputs));
3903        if let Some(val) = locktime {
3904            rpc_params.push(serde_json::json!(val));
3905        }
3906        if let Some(val) = options {
3907            rpc_params.push(serde_json::json!(val));
3908        }
3909        if let Some(val) = bip32derivs {
3910            rpc_params.push(serde_json::json!(val));
3911        }
3912        if let Some(val) = version {
3913            rpc_params.push(serde_json::json!(val));
3914        }
3915        self.call::<WalletCreateFundedPsbtResponse>("walletcreatefundedpsbt", &rpc_params).await
3916    }
3917
3918    /// Display address on an external signer for verification.
3919    async fn wallet_display_address(
3920        &self,
3921        address: bitcoin::Address,
3922    ) -> Result<WalletDisplayAddressResponse, Self::Error> {
3923        let mut rpc_params = vec![];
3924        rpc_params.push(serde_json::json!(address));
3925        self.call::<WalletDisplayAddressResponse>("walletdisplayaddress", &rpc_params).await
3926    }
3927
3928    /// Removes the wallet encryption key from memory, locking the wallet.
3929    /// After calling this method, you will need to call walletpassphrase again
3930    /// before being able to call any methods which require the wallet to be unlocked.
3931    async fn wallet_lock(&self) -> Result<WalletLockResponse, Self::Error> {
3932        self.call::<WalletLockResponse>("walletlock", &[]).await
3933    }
3934
3935    /// Stores the wallet decryption key in memory for 'timeout' seconds.
3936    /// This is needed prior to performing transactions related to private keys such as sending bitcoins
3937    /// Note:
3938    /// Issuing the walletpassphrase command while the wallet is already unlocked will set a new unlock
3939    /// time that overrides the old one.
3940    async fn wallet_passphrase(
3941        &self,
3942        passphrase: String,
3943        timeout: i64,
3944    ) -> Result<WalletPassphraseResponse, Self::Error> {
3945        let mut rpc_params = vec![];
3946        rpc_params.push(serde_json::json!(passphrase));
3947        rpc_params.push(serde_json::json!(timeout));
3948        self.call::<WalletPassphraseResponse>("walletpassphrase", &rpc_params).await
3949    }
3950
3951    /// Changes the wallet passphrase from 'oldpassphrase' to 'newpassphrase'.
3952    async fn wallet_passphrase_change(
3953        &self,
3954        oldpassphrase: String,
3955        newpassphrase: String,
3956    ) -> Result<WalletPassphraseChangeResponse, Self::Error> {
3957        let mut rpc_params = vec![];
3958        rpc_params.push(serde_json::json!(oldpassphrase));
3959        rpc_params.push(serde_json::json!(newpassphrase));
3960        self.call::<WalletPassphraseChangeResponse>("walletpassphrasechange", &rpc_params).await
3961    }
3962
3963    /// Update a PSBT with input information from our wallet and then sign inputs
3964    /// that we can sign for.
3965    /// Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.
3966    async fn wallet_process_psbt(
3967        &self,
3968        psbt: String,
3969        sign: Option<bool>,
3970        sighashtype: Option<String>,
3971        bip32derivs: Option<bool>,
3972        finalize: Option<bool>,
3973    ) -> Result<WalletProcessPsbtResponse, Self::Error> {
3974        let mut rpc_params = vec![];
3975        rpc_params.push(serde_json::json!(psbt));
3976        if let Some(val) = sign {
3977            rpc_params.push(serde_json::json!(val));
3978        }
3979        if let Some(val) = sighashtype {
3980            rpc_params.push(serde_json::json!(val));
3981        }
3982        if let Some(val) = bip32derivs {
3983            rpc_params.push(serde_json::json!(val));
3984        }
3985        if let Some(val) = finalize {
3986            rpc_params.push(serde_json::json!(val));
3987        }
3988        self.call::<WalletProcessPsbtResponse>("walletprocesspsbt", &rpc_params).await
3989    }
3990}