BitcoinTestClient

Struct BitcoinTestClient 

Source
pub struct BitcoinTestClient { /* private fields */ }

Implementations§

Source§

impl BitcoinTestClient

Source

pub async fn new() -> Result<Self, TransportError>

Creates a new Bitcoin test client with default configuration (regtest network).

use bitcoin_rpc_midas::test_node::client::BitcoinTestClient;

async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let client = BitcoinTestClient::new().await?;
    Ok(())
}
Source

pub async fn new_with_network(network: Network) -> Result<Self, TransportError>

Creates a new Bitcoin test client with a specific network.

use bitcoin_rpc_midas::test_node::client::BitcoinTestClient;
use bitcoin::Network;

async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let client = BitcoinTestClient::new_with_network(Network::Bitcoin).await?;
    Ok(())
}
Source

pub async fn new_with_manager<M: NodeManagerTrait + 'static>( node_manager: M, ) -> Result<Self, TransportError>

Creates a new Bitcoin test client with a specific node manager. This allows for custom node configuration and lifecycle management. The node manager must implement the NodeManager trait.

use bitcoin_rpc_midas::test_node::client::BitcoinTestClient;
use bitcoin_rpc_midas::node::BitcoinNodeManager;
use bitcoin_rpc_midas::test_config::TestConfig;

async fn example() -> Result<(), Box<dyn std::error::Error>> {
    let config = TestConfig::default();
    let node_manager = BitcoinNodeManager::new_with_config(&config)?;
    let client = BitcoinTestClient::new_with_manager(node_manager).await?;
    Ok(())
}
Source

pub async fn ensure_wallet_with_options( &mut self, wallet_name: impl Into<String>, opts: WalletOptions, ) -> Result<String, TransportError>

Ensures a wallet exists using the given options. Loads the wallet if it already exists. Returns the wallet name.

Source

pub async fn ensure_default_wallet( &mut self, name: impl Into<String>, ) -> Result<String, TransportError>

Shortcut for ensure_wallet_with_options("test_wallet", WalletOptions::default().with_descriptors())

Source

pub async fn mine_blocks( &mut self, num_blocks: u64, maxtries: u64, ) -> Result<(String, Value), TransportError>

Helper method to mine blocks to a new address

Source

pub async fn reset_chain(&mut self) -> Result<(), TransportError>

Resets the blockchain to a clean state. This method:

  1. First attempts to prune the blockchain to height 0
  2. If blocks remain, invalidates all blocks except genesis
  3. Reconsiders the genesis block to maintain a valid chain
Source

pub async fn stop_node(&mut self) -> Result<(), TransportError>

Stops the Bitcoin node if one is running. This is automatically called when the client is dropped.

Source

pub fn node_manager(&self) -> Option<&dyn NodeManagerTrait>

Returns a reference to the node manager if one exists. This can be used to access node configuration and control the node lifecycle.

Source

pub fn rpc(&self) -> &RpcClient

Give callers the full RPC client (incl. .batch())

Source

pub fn batch(&self) -> BatchBuilder

Begin a JSON-RPC batch against this test node

Source

pub async fn abandontransaction(&self, txid: Txid) -> Result<(), TransportError>

Mark in-wallet transaction as abandoned This will mark this transaction and all its in-wallet descendants as abandoned which will allow for their inputs to be respent. It can be used to replace “stuck” or evicted transactions. It only works on transactions which are not included in a block and are not currently in the mempool. It has no effect on transactions which are already abandoned.

Source

pub async fn abortrescan(&self) -> Result<AbortrescanResponse, TransportError>

Stops current wallet rescan triggered by an RPC call, e.g. by a rescanblockchain call. Note: Use “getwalletinfo” to query the scanning progress.

Source

pub async fn addconnection( &self, address: String, connection_type: String, v2transport: bool, ) -> Result<AddconnectionResponse, TransportError>

Open an outbound connection to a specified node. This RPC is for testing only.

Source

pub async fn addnode( &self, node: String, command: String, v2transport: bool, ) -> Result<(), TransportError>

Attempts to add or remove a node from the addnode list. Or try a connection to a node once. Nodes added using addnode (or -connect) are protected from DoS disconnection and are not required to be full nodes/support SegWit as other outbound peers are (though such peers will not be synced from). Addnode connections are limited to 8 at a time and are counted separately from the -maxconnections limit.

Source

pub async fn addpeeraddress( &self, address: String, port: u16, tried: bool, ) -> Result<AddpeeraddressResponse, TransportError>

Add the address of a potential peer to an address manager table. This RPC is for testing only.

Source

pub async fn analyzepsbt( &self, psbt: String, ) -> Result<AnalyzepsbtResponse, TransportError>

Analyzes and provides information about the current status of a PSBT and its inputs

Source

pub async fn backupwallet( &self, destination: String, ) -> Result<(), TransportError>

Safely copies the current wallet file to the specified destination, which can either be a directory or a path with a filename.

Source

pub async fn bumpfee( &self, txid: Txid, options: Value, ) -> Result<BumpfeeResponse, TransportError>

Bumps the fee of a transaction T, replacing it with a new transaction B. A transaction with the given txid must be in the wallet. The command will pay the additional fee by reducing change outputs or adding inputs when necessary. It may add a new change output if one does not already exist. All inputs in the original transaction will be included in the replacement transaction. The command will fail if the wallet or mempool contains a transaction that spends one of T“s outputs. By default, the new fee will be calculated automatically using the estimatesmartfee RPC. The user can specify a confirmation target for estimatesmartfee. Alternatively, the user can specify a fee rate in sat/vB for the new transaction. At a minimum, the new fee rate must be high enough to pay an additional new relay fee (incrementalfee returned by getnetworkinfo) to enter the node“s mempool.

  • WARNING: before version 0.21, fee_rate was in BTC/kvB. As of 0.21, fee_rate is in sat/vB. *
Source

pub async fn clearbanned(&self) -> Result<(), TransportError>

Clear all banned IPs.

Source

pub async fn combinepsbt( &self, txs: Vec<Value>, ) -> Result<CombinepsbtResponse, TransportError>

Combine multiple partially signed Bitcoin transactions into one transaction. Implements the Combiner role.

Source

pub async fn combinerawtransaction( &self, txs: Vec<Value>, ) -> Result<CombinerawtransactionResponse, TransportError>

Combine multiple partially signed transactions into one transaction. The combined transaction may be another partially signed transaction or a fully signed transaction.

Source

pub async fn converttopsbt( &self, hexstring: String, permitsigdata: bool, iswitness: bool, ) -> Result<ConverttopsbtResponse, TransportError>

Converts a network serialized transaction to a PSBT. This should be used only with createrawtransaction and fundrawtransaction createpsbt and walletcreatefundedpsbt should be used for new applications.

Source

pub async fn createmultisig( &self, nrequired: u32, keys: Vec<String>, address_type: String, ) -> Result<CreatemultisigResponse, TransportError>

Creates a multi-signature address with n signatures of m keys required. It returns a json object with the address and redeemScript.

Source

pub async fn createpsbt( &self, inputs: Vec<Value>, outputs: Vec<Value>, locktime: u32, replaceable: bool, version: u32, ) -> Result<CreatepsbtResponse, TransportError>

Creates a transaction in the Partially Signed Transaction format. Implements the Creator role. Note that the transaction“s inputs are not signed, and it is not stored in the wallet or transmitted to the network.

Source

pub async fn createrawtransaction( &self, inputs: Vec<Value>, outputs: Vec<Value>, locktime: u32, replaceable: bool, version: u32, ) -> Result<CreaterawtransactionResponse, TransportError>

Create a transaction spending the given inputs and creating new outputs. Outputs can be addresses or data. Returns hex-encoded raw transaction. Note that the transaction“s inputs are not signed, and it is not stored in the wallet or transmitted to the network.

Source

pub async fn createwallet( &self, wallet_name: String, disable_private_keys: bool, blank: bool, passphrase: String, avoid_reuse: bool, descriptors: bool, load_on_startup: bool, external_signer: bool, ) -> Result<CreatewalletResponse, TransportError>

Creates and loads a new wallet.

Source

pub async fn createwalletdescriptor( &self, _type: String, options: Value, ) -> Result<CreatewalletdescriptorResponse, TransportError>

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. Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.

Source

pub async fn decodepsbt( &self, psbt: String, ) -> Result<DecodepsbtResponse, TransportError>

Return a JSON object representing the serialized, base64-encoded partially signed Bitcoin transaction.

Source

pub async fn decoderawtransaction( &self, hexstring: String, iswitness: bool, ) -> Result<DecoderawtransactionResponse, TransportError>

Return a JSON object representing the serialized, hex-encoded transaction.

Source

pub async fn decodescript( &self, hexstring: String, ) -> Result<DecodescriptResponse, TransportError>

Decode a hex-encoded script.

Source

pub async fn deriveaddresses( &self, descriptor: String, range: Value, ) -> Result<DeriveaddressesResponse, TransportError>

Derives one or more addresses corresponding to an output descriptor. Examples of output descriptors are: pkh() P2PKH outputs for the given pubkey wpkh() Native segwit P2PKH outputs for the given pubkey sh(multi(,,,…)) P2SH-multisig outputs for the given threshold and pubkeys raw() Outputs whose output script equals the specified hex-encoded bytes tr(,multi_a(,,,…)) P2TR-multisig outputs for the given threshold and pubkeys

In the above, either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one or more path elements separated by “/”, where “h” represents a hardened child key. For more information on output descriptors, see the documentation in the doc/descriptors.md file.

Source

pub async fn descriptorprocesspsbt( &self, psbt: String, descriptors: Vec<Value>, sighashtype: String, bip32derivs: bool, finalize: bool, ) -> Result<DescriptorprocesspsbtResponse, TransportError>

Update all segwit inputs in a PSBT with information from output descriptors, the UTXO set or the mempool. Then, sign the inputs we are able to with information from the output descriptors.

Source

pub async fn disconnectnode( &self, address: String, nodeid: u64, ) -> Result<(), TransportError>

Immediately disconnects from the specified peer node.

Strictly one out of “address” and “nodeid” can be provided to identify the node.

To disconnect by nodeid, either set “address” to the empty string, or call using the named “nodeid” argument only.

Source

pub async fn dumptxoutset( &self, path: String, _type: String, options: Value, ) -> Result<DumptxoutsetResponse, TransportError>

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.

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.

This call may take several minutes. Make sure to use no RPC timeout (bitcoin-cli -rpcclienttimeout=0)

Source

pub async fn echo( &self, arg0: String, arg1: String, arg2: String, arg3: String, arg4: String, arg5: String, arg6: String, arg7: String, arg8: String, arg9: String, ) -> Result<EchoResponse, TransportError>

Simply echo back the input arguments. This command is for testing.

It will return an internal bug report when arg9=“trigger_internal_bug” is passed.

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.

Source

pub async fn echoipc( &self, arg: String, ) -> Result<EchoipcResponse, TransportError>

Echo back the input argument, passing it through a spawned process in a multiprocess build. This command is for testing.

Source

pub async fn echojson( &self, arg0: String, arg1: String, arg2: String, arg3: String, arg4: String, arg5: String, arg6: String, arg7: String, arg8: String, arg9: String, ) -> Result<EchojsonResponse, TransportError>

Simply echo back the input arguments. This command is for testing.

It will return an internal bug report when arg9=“trigger_internal_bug” is passed.

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.

Source

pub async fn encryptwallet( &self, passphrase: String, ) -> Result<EncryptwalletResponse, TransportError>

Encrypts the wallet with “passphrase”. This is for first time encryption. After this, any calls that interact with private keys such as sending or signing will require the passphrase to be set prior to making these calls. Use the walletpassphrase call for this, and then walletlock call. If the wallet is already encrypted, use the walletpassphrasechange call. ** IMPORTANT ** For security reasons, the encryption process will generate a new HD seed, resulting in the creation of a fresh set of active descriptors. Therefore, it is crucial to securely back up the newly generated wallet file using the backupwallet RPC.

Source

pub async fn enumeratesigners( &self, ) -> Result<EnumeratesignersResponse, TransportError>

Returns a list of external signers from -signer.

Source

pub async fn estimaterawfee( &self, conf_target: u64, threshold: u64, ) -> Result<EstimaterawfeeResponse, TransportError>

WARNING: This interface is unstable and may disappear or change!

WARNING: This is an advanced API call that is tightly coupled to the specific implementation of fee estimation. The parameters it can be called with and the results it returns will change if the internal implementation changes.

Estimates the approximate fee per kilobyte needed for a transaction to begin confirmation within conf_target blocks if possible. Uses virtual transaction size as defined in BIP 141 (witness data is discounted).

Source

pub async fn estimatesmartfee( &self, conf_target: u64, estimate_mode: String, ) -> Result<EstimatesmartfeeResponse, TransportError>

Estimates the approximate fee per kilobyte needed for a transaction to begin confirmation within conf_target blocks if possible and return the number of blocks for which the estimate is valid. Uses virtual transaction size as defined in BIP 141 (witness data is discounted).

Source

pub async fn finalizepsbt( &self, psbt: String, extract: bool, ) -> Result<FinalizepsbtResponse, TransportError>

Finalize the inputs of a PSBT. If the transaction is fully signed, it will produce a network serialized transaction which can be broadcast with sendrawtransaction. Otherwise a PSBT will be created which has the final_scriptSig and final_scriptwitness fields filled for inputs that are complete. Implements the Finalizer and Extractor roles.

Source

pub async fn fundrawtransaction( &self, hexstring: String, options: Value, iswitness: bool, ) -> Result<FundrawtransactionResponse, TransportError>

If the transaction has no inputs, they will be automatically selected to meet its out value. It will add at most one change output to the outputs. No existing outputs will be modified unless “subtractFeeFromOutputs” is specified. Note that inputs which were signed may need to be resigned after completion since in/outputs have been added. The inputs added will not be signed, use signrawtransactionwithkey or signrawtransactionwithwallet for that. All existing inputs must either have their previous output transaction be in the wallet or be in the UTXO set. Solving data must be provided for non-wallet inputs. Note that all inputs selected must be of standard form and P2SH scripts must be in the wallet using importdescriptors (to calculate fees). You can see whether this is the case by checking the “solvable” field in the listunspent output. Note that if specifying an exact fee rate, the resulting transaction may have a higher fee rate if the transaction has unconfirmed inputs. This is because the wallet will attempt to make the entire package have the given fee rate, not the resulting transaction.

Source

pub async fn generate(&self) -> Result<(), TransportError>

has been replaced by the -generate cli option. Refer to -help for more information.

Source

pub async fn generateblock( &self, output: String, transactions: Vec<Value>, submit: bool, ) -> Result<GenerateblockResponse, TransportError>

Mine a set of ordered transactions to a specified address or descriptor and return the block hash.

Source

pub async fn generatetoaddress( &self, nblocks: u64, address: String, maxtries: u64, ) -> Result<GeneratetoaddressResponse, TransportError>

Mine to a specified address and return the block hashes.

Source

pub async fn generatetodescriptor( &self, num_blocks: u64, descriptor: String, maxtries: u64, ) -> Result<GeneratetodescriptorResponse, TransportError>

Mine to a specified descriptor and return the block hashes.

Source

pub async fn getaddednodeinfo( &self, node: String, ) -> Result<GetaddednodeinfoResponse, TransportError>

Returns information about the given added node, or all added nodes (note that onetry addnodes are not listed here)

Source

pub async fn getaddressesbylabel( &self, label: String, ) -> Result<GetaddressesbylabelResponse, TransportError>

Returns the list of addresses assigned the specified label.

Source

pub async fn getaddressinfo( &self, address: String, ) -> Result<GetaddressinfoResponse, TransportError>

Return information about the given bitcoin address. Some of the information will only be present if the address is in the active wallet.

Source

pub async fn getaddrmaninfo( &self, ) -> Result<GetaddrmaninfoResponse, TransportError>

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.

Source

pub async fn getbalance( &self, dummy: Option<String>, minconf: u32, include_watchonly: bool, avoid_reuse: bool, ) -> Result<GetbalanceResponse, TransportError>

Returns the total available balance. The available balance is what the wallet considers currently spendable, and is thus affected by options which limit spendability such as -spendzeroconfchange.

Source

pub async fn getbalances(&self) -> Result<GetbalancesResponse, TransportError>

Returns an object with all balances in BTC.

Source

pub async fn getbestblockhash( &self, ) -> Result<GetbestblockhashResponse, TransportError>

Returns the hash of the best (tip) block in the most-work fully-validated chain.

Source

pub async fn getblock( &self, blockhash: BlockHash, verbosity: u32, ) -> Result<GetblockResponse, TransportError>

If verbosity is 0, returns a string that is serialized, hex-encoded data for block “hash”. If verbosity is 1, returns an Object with information about block . If verbosity is 2, returns an Object with information about block and information about each transaction. If verbosity is 3, returns an Object with information about block and information about each transaction, including prevout information for inputs (only for unpruned blocks in the current best chain).

Source

pub async fn getblockchaininfo( &self, ) -> Result<GetblockchaininfoResponse, TransportError>

Returns an object containing various state info regarding blockchain processing.

Source

pub async fn getblockcount( &self, ) -> Result<GetblockcountResponse, TransportError>

Returns the height of the most-work fully-validated chain. The genesis block has height 0.

Source

pub async fn getblockfilter( &self, blockhash: BlockHash, filtertype: String, ) -> Result<GetblockfilterResponse, TransportError>

Retrieve a BIP 157 content filter for a particular block.

Source

pub async fn getblockfrompeer( &self, blockhash: BlockHash, peer_id: u64, ) -> Result<GetblockfrompeerResponse, TransportError>

Attempt to fetch block from a given peer.

We must have the header for this block, e.g. using submitheader. 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. Subsequent calls for the same block may cause the response from the previous peer to be ignored. Peers generally ignore requests for a stale block that they never fully verified, or one that is more than a month old. When a peer does not respond with a block, we will disconnect. Note: The block could be re-pruned as soon as it is received.

Returns an empty JSON object if the request was successfully scheduled.

Source

pub async fn getblockhash( &self, height: u64, ) -> Result<GetblockhashResponse, TransportError>

Returns hash of block in best-block-chain at height provided.

Source

pub async fn getblockheader( &self, blockhash: BlockHash, verbose: bool, ) -> Result<GetblockheaderResponse, TransportError>

If verbose is false, returns a string that is serialized, hex-encoded data for blockheader “hash”. If verbose is true, returns an Object with information about blockheader .

Source

pub async fn getblockstats( &self, hash_or_height: HashOrHeight, stats: Vec<String>, ) -> Result<GetblockstatsResponse, TransportError>

Compute per block statistics for a given window. All amounts are in satoshis. It won“t work for some heights with pruning.

Source

pub async fn getblocktemplate( &self, template_request: Value, ) -> Result<(), TransportError>

If the request parameters include a “mode” key, that is used to explicitly select between the default “template” request or a “proposal”. It returns data needed to construct a block to work on. For full specification, see BIPs 22, 23, 9, and 145: https://github.com/bitcoin/bips/blob/master/bip-0022.mediawiki https://github.com/bitcoin/bips/blob/master/bip-0023.mediawiki https://github.com/bitcoin/bips/blob/master/bip-0009.mediawiki#getblocktemplate_changes https://github.com/bitcoin/bips/blob/master/bip-0145.mediawiki

Source

pub async fn getchainstates( &self, ) -> Result<GetchainstatesResponse, TransportError>

Return information about chainstates.

Source

pub async fn getchaintips(&self) -> Result<GetchaintipsResponse, TransportError>

Return information about all known tips in the block tree, including the main chain as well as orphaned branches.

Source

pub async fn getchaintxstats( &self, nblocks: u64, blockhash: BlockHash, ) -> Result<GetchaintxstatsResponse, TransportError>

Compute statistics about the total number and rate of transactions in the chain.

Source

pub async fn getconnectioncount( &self, ) -> Result<GetconnectioncountResponse, TransportError>

Returns the number of connections to other nodes.

Source

pub async fn getdeploymentinfo( &self, blockhash: BlockHash, ) -> Result<GetdeploymentinfoResponse, TransportError>

Returns an object containing various state info regarding deployments of consensus changes.

Source

pub async fn getdescriptoractivity( &self, blockhashes: Vec<Value>, scanobjects: Vec<Value>, include_mempool: bool, ) -> Result<GetdescriptoractivityResponse, TransportError>

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(). This call may take several minutes. If you encounter timeouts, try specifying no RPC timeout (bitcoin-cli -rpcclienttimeout=0)

Source

pub async fn getdescriptorinfo( &self, descriptor: String, ) -> Result<GetdescriptorinfoResponse, TransportError>

Analyses a descriptor.

Source

pub async fn getdifficulty( &self, ) -> Result<GetdifficultyResponse, TransportError>

Returns the proof-of-work difficulty as a multiple of the minimum difficulty.

Source

pub async fn gethdkeys( &self, options: Value, ) -> Result<GethdkeysResponse, TransportError>

List all BIP 32 HD keys in the wallet and which descriptors use them.

Source

pub async fn getindexinfo( &self, index_name: String, ) -> Result<GetindexinfoResponse, TransportError>

Returns the status of one or all available indices currently running in the node.

Source

pub async fn getmemoryinfo( &self, mode: String, ) -> Result<GetmemoryinfoResponse, TransportError>

Returns an object containing information about memory usage.

Source

pub async fn getmempoolancestors( &self, txid: Txid, verbose: bool, ) -> Result<GetmempoolancestorsResponse, TransportError>

If txid is in the mempool, returns all in-mempool ancestors.

Source

pub async fn getmempooldescendants( &self, txid: Txid, verbose: bool, ) -> Result<GetmempooldescendantsResponse, TransportError>

If txid is in the mempool, returns all in-mempool descendants.

Source

pub async fn getmempoolentry( &self, txid: Txid, ) -> Result<GetmempoolentryResponse, TransportError>

Returns mempool data for given transaction

Source

pub async fn getmempoolinfo( &self, ) -> Result<GetmempoolinfoResponse, TransportError>

Returns details on the active state of the TX memory pool.

Source

pub async fn getmininginfo( &self, ) -> Result<GetmininginfoResponse, TransportError>

Returns a json object containing mining-related information.

Source

pub async fn getnettotals(&self) -> Result<GetnettotalsResponse, TransportError>

Returns information about network traffic, including bytes in, bytes out, and current system time.

Source

pub async fn getnetworkhashps( &self, nblocks: u64, height: u64, ) -> Result<GetnetworkhashpsResponse, TransportError>

Returns the estimated network hashes per second based on the last n blocks. Pass in [blocks] to override # of blocks, -1 specifies since last difficulty change. Pass in [height] to estimate the network speed at the time when a certain block was found.

Source

pub async fn getnetworkinfo( &self, ) -> Result<GetnetworkinfoResponse, TransportError>

Returns an object containing various state info regarding P2P networking.

Source

pub async fn getnewaddress( &self, label: String, address_type: String, ) -> Result<GetnewaddressResponse, TransportError>

Returns a new Bitcoin address for receiving payments. If “label” is specified, it is added to the address book so payments received with the address will be associated with “label”.

Source

pub async fn getnodeaddresses( &self, count: u64, network: String, ) -> Result<GetnodeaddressesResponse, TransportError>

Return known addresses, after filtering for quality and recency. These can potentially be used to find new peers in the network. The total number of addresses known to the node may be higher.

Source

pub async fn getorphantxs( &self, verbosity: u32, ) -> Result<GetorphantxsResponse, TransportError>

Shows transactions in the tx orphanage.

EXPERIMENTAL warning: this call may be changed in future releases.

Source

pub async fn getpeerinfo(&self) -> Result<GetpeerinfoResponse, TransportError>

Returns data about each connected network peer as a json array of objects.

Source

pub async fn getprioritisedtransactions( &self, ) -> Result<GetprioritisedtransactionsResponse, TransportError>

Returns a map of all user-created (see prioritisetransaction) fee deltas by txid, and whether the tx is present in mempool.

Source

pub async fn getrawaddrman( &self, ) -> Result<GetrawaddrmanResponse, TransportError>

EXPERIMENTAL warning: this call may be changed in future releases.

Returns information on all address manager entries for the new and tried tables.

Source

pub async fn getrawchangeaddress( &self, address_type: String, ) -> Result<GetrawchangeaddressResponse, TransportError>

Returns a new Bitcoin address, for receiving change. This is for use with raw transactions, NOT normal use.

Source

pub async fn getrawmempool( &self, verbose: bool, mempool_sequence: bool, ) -> Result<GetrawmempoolResponse, TransportError>

Returns all transaction ids in memory pool as a json array of string transaction ids.

Hint: use getmempoolentry to fetch a specific transaction from the mempool.

Source

pub async fn getrawtransaction( &self, txid: Txid, verbosity: u32, blockhash: BlockHash, ) -> Result<GetrawtransactionResponse, TransportError>

By default, this call only returns a transaction if it is in the mempool. If -txindex is enabled and no blockhash argument is passed, it will return the transaction if it is in the mempool or any block. If a blockhash argument is passed, it will return the transaction if the specified block is available and the transaction is in that block.

Hint: Use gettransaction for wallet transactions.

If verbosity is 0 or omitted, returns the serialized transaction as a hex-encoded string. If verbosity is 1, returns a JSON Object with information about the transaction. If verbosity is 2, returns a JSON Object with information about the transaction, including fee and prevout information.

Source

pub async fn getreceivedbyaddress( &self, address: String, minconf: u32, include_immature_coinbase: bool, ) -> Result<GetreceivedbyaddressResponse, TransportError>

Returns the total amount received by the given address in transactions with at least minconf confirmations.

Source

pub async fn getreceivedbylabel( &self, label: String, minconf: u32, include_immature_coinbase: bool, ) -> Result<GetreceivedbylabelResponse, TransportError>

Returns the total amount received by addresses with

Source

pub async fn getrpcinfo(&self) -> Result<GetrpcinfoResponse, TransportError>

Returns details of the RPC server.

Source

pub async fn gettransaction( &self, txid: Txid, include_watchonly: bool, verbose: bool, ) -> Result<GettransactionResponse, TransportError>

Get detailed information about in-wallet transaction

Source

pub async fn gettxout( &self, txid: Txid, n: u32, include_mempool: bool, ) -> Result<(), TransportError>

Returns details about an unspent transaction output.

Source

pub async fn gettxoutproof( &self, txids: Vec<Txid>, blockhash: BlockHash, ) -> Result<GettxoutproofResponse, TransportError>

Returns a hex-encoded proof that “txid” was included in a block.

NOTE: By default this function only works sometimes. This is when there is an unspent output in the utxo for this transaction. To make it always work, you need to maintain a transaction index, using the -txindex command line option or specify the block in which the transaction is included manually (by blockhash).

Source

pub async fn gettxoutsetinfo( &self, hash_type: String, hash_or_height: HashOrHeight, use_index: bool, ) -> Result<GettxoutsetinfoResponse, TransportError>

Returns statistics about the unspent transaction output set. Note this call may take some time if you are not using coinstatsindex.

Source

pub async fn gettxspendingprevout( &self, outputs: Vec<Value>, ) -> Result<GettxspendingprevoutResponse, TransportError>

Scans the mempool to find transactions spending any of the given outputs

Source

pub async fn getwalletinfo( &self, ) -> Result<GetwalletinfoResponse, TransportError>

Returns an object containing various wallet state info.

Source

pub async fn getzmqnotifications( &self, ) -> Result<GetzmqnotificationsResponse, TransportError>

Returns information about the active ZeroMQ notifications.

Source

pub async fn help( &self, command: String, ) -> Result<HelpResponse, TransportError>

List all commands, or get help for a specified command.

Source

pub async fn importdescriptors( &self, requests: Vec<Value>, ) -> Result<ImportdescriptorsResponse, TransportError>

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. 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.

Note: This call can take over an hour to complete if using an early timestamp; during that time, other rpc calls may report that the imported keys, addresses or scripts exist but related transactions are still missing. The rescan is significantly faster if block filters are available (using startup option “-blockfilterindex=1”).

Source

pub async fn importmempool( &self, filepath: String, options: Value, ) -> Result<ImportmempoolResponse, TransportError>

Import a mempool.dat file and attempt to add its contents to the mempool. Warning: Importing untrusted files is dangerous, especially if metadata from the file is taken over.

Source

pub async fn importprunedfunds( &self, rawtransaction: String, txoutproof: String, ) -> Result<(), TransportError>

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.

Source

pub async fn invalidateblock( &self, blockhash: BlockHash, ) -> Result<(), TransportError>

Permanently marks a block as invalid, as if it violated a consensus rule.

Source

pub async fn joinpsbts( &self, txs: Vec<Value>, ) -> Result<JoinpsbtsResponse, TransportError>

Joins multiple distinct PSBTs with different inputs and outputs into one PSBT with inputs and outputs from all of the PSBTs No input in any of the PSBTs can be in more than one of the PSBTs.

Source

pub async fn keypoolrefill(&self, newsize: u64) -> Result<(), TransportError>

Refills each descriptor keypool in the wallet up to the specified number of new keys. By default, descriptor wallets have 4 active ranged descriptors (“legacy”, “p2sh-segwit”, “bech32”, “bech32m”), each with 1000 entries.

Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.

Source

pub async fn listaddressgroupings( &self, ) -> Result<ListaddressgroupingsResponse, TransportError>

Lists groups of addresses which have had their common ownership made public by common use as inputs or as the resulting change in past transactions

Source

pub async fn listbanned(&self) -> Result<ListbannedResponse, TransportError>

List all manually banned IPs/Subnets.

Source

pub async fn listdescriptors( &self, private: bool, ) -> Result<ListdescriptorsResponse, TransportError>

List all descriptors present in a wallet.

Source

pub async fn listlabels( &self, purpose: String, ) -> Result<ListlabelsResponse, TransportError>

Returns the list of all labels, or labels that are assigned to addresses with a specific purpose.

Source

pub async fn listlockunspent( &self, ) -> Result<ListlockunspentResponse, TransportError>

Returns list of temporarily unspendable outputs. See the lockunspent call to lock and unlock transactions for spending.

Source

pub async fn listreceivedbyaddress( &self, minconf: u32, include_empty: bool, include_watchonly: bool, address_filter: String, include_immature_coinbase: bool, ) -> Result<ListreceivedbyaddressResponse, TransportError>

List balances by receiving address.

Source

pub async fn listreceivedbylabel( &self, minconf: u32, include_empty: bool, include_watchonly: bool, include_immature_coinbase: bool, ) -> Result<ListreceivedbylabelResponse, TransportError>

List received transactions by label.

Source

pub async fn listsinceblock( &self, blockhash: BlockHash, target_confirmations: u64, include_watchonly: bool, include_removed: bool, include_change: bool, label: String, ) -> Result<ListsinceblockResponse, TransportError>

Get all transactions in blocks since block [blockhash], or all transactions if omitted. If “blockhash” is no longer a part of the main chain, transactions from the fork point onward are included. Additionally, if include_removed is set, transactions affecting the wallet which were removed are returned in the “removed” array.

Source

pub async fn listtransactions( &self, label: String, count: u64, skip: u64, include_watchonly: bool, ) -> Result<ListtransactionsResponse, TransportError>

If a label name is provided, this will return only incoming transactions paying to addresses with the specified label.

Returns up to “count” most recent transactions skipping the first “from” transactions.

Source

pub async fn listunspent( &self, minconf: u32, maxconf: u32, addresses: Vec<String>, include_unsafe: bool, query_options: Value, ) -> Result<ListunspentResponse, TransportError>

Returns array of unspent transaction outputs with between minconf and maxconf (inclusive) confirmations. Optionally filter to only include txouts paid to specified addresses.

Source

pub async fn listwalletdir( &self, ) -> Result<ListwalletdirResponse, TransportError>

Returns a list of wallets in the wallet directory.

Source

pub async fn listwallets(&self) -> Result<ListwalletsResponse, TransportError>

Returns a list of currently loaded wallets. For full information on the wallet, use “getwalletinfo”

Source

pub async fn loadtxoutset( &self, path: String, ) -> Result<LoadtxoutsetResponse, TransportError>

Load the serialized UTXO set from a file. 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.

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.

You can find more information on this process in the assumeutxo design document (https://github.com/bitcoin/bitcoin/blob/master/doc/design/assumeutxo.md).

Source

pub async fn loadwallet( &self, filename: String, load_on_startup: bool, ) -> Result<LoadwalletResponse, TransportError>

Loads a wallet from a wallet file or directory. Note that all wallet command-line options used when starting bitcoind will be applied to the new wallet.

Source

pub async fn lockunspent( &self, unlock: bool, transactions: Vec<Value>, persistent: bool, ) -> Result<LockunspentResponse, TransportError>

Updates list of temporarily unspendable outputs. Temporarily lock (unlock=false) or unlock (unlock=true) specified transaction outputs. If no transaction outputs are specified when unlocking then all current locked transaction outputs are unlocked. A locked transaction output will not be chosen by automatic coin selection, when spending bitcoins. Manually selected coins are automatically unlocked. Locks are stored in memory only, unless persistent=true, in which case they will be written to the wallet database and loaded on node start. Unwritten (persistent=false) locks are always cleared (by virtue of process exit) when a node stops or fails. Unlocking will clear both persistent and not. Also see the listunspent call

Source

pub async fn logging( &self, include: Vec<Value>, exclude: Vec<Value>, ) -> Result<LoggingResponse, TransportError>

Gets and sets the logging configuration. When called without an argument, returns the list of categories with status that are currently being debug logged or not. When called with arguments, adds or removes categories from debug logging and return the lists above. The arguments are evaluated in order “include”, “exclude”. If an item is both included and excluded, it will thus end up being excluded. The valid logging categories are: addrman, bench, blockstorage, cmpctblock, coindb, estimatefee, http, i2p, ipc, leveldb, libevent, mempool, mempoolrej, net, proxy, prune, qt, rand, reindex, rpc, scan, selectcoins, tor, txpackages, txreconciliation, validation, walletdb, zmq In addition, the following are available as category names with special meanings:

  • “all”, “1” : represent all logging categories.
Source

pub async fn migratewallet( &self, wallet_name: String, passphrase: String, ) -> Result<MigratewalletResponse, TransportError>

Migrate the wallet to a descriptor wallet. A new wallet backup will need to be made.

The migration process will create a backup of the wallet before migrating. This backup file will be named -.legacy.bak and can be found in the directory for this wallet. In the event of an incorrect migration, the backup can be restored using restorewallet. Encrypted wallets must have the passphrase provided as an argument to this call.

This RPC may take a long time to complete. Increasing the RPC client timeout is recommended.

Source

pub async fn mockscheduler(&self, delta_time: u64) -> Result<(), TransportError>

Bump the scheduler into the future (-regtest only)

Source

pub async fn ping(&self) -> Result<(), TransportError>

Requests that a ping be sent to all other nodes, to measure ping time. Results are provided in getpeerinfo. Ping command is handled in queue with all other commands, so it measures processing backlog, not just network ping.

Source

pub async fn preciousblock( &self, blockhash: BlockHash, ) -> Result<(), TransportError>

Treats a block as if it were received before others with the same work.

A later preciousblock call can override the effect of an earlier one.

The effects of preciousblock are not retained across restarts.

Source

pub async fn prioritisetransaction( &self, txid: Txid, dummy: Option<String>, fee_delta: f64, ) -> Result<PrioritisetransactionResponse, TransportError>

Accepts the transaction into mined blocks at a higher (or lower) priority

Source

pub async fn pruneblockchain( &self, height: u64, ) -> Result<PruneblockchainResponse, TransportError>

Attempts to delete block and undo data up to a specified height or timestamp, if eligible for pruning. 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.

Source

pub async fn psbtbumpfee( &self, txid: Txid, options: Value, ) -> Result<PsbtbumpfeeResponse, TransportError>

Bumps the fee of a transaction T, replacing it with a new transaction B. Returns a PSBT instead of creating and signing a new transaction. A transaction with the given txid must be in the wallet. The command will pay the additional fee by reducing change outputs or adding inputs when necessary. It may add a new change output if one does not already exist. All inputs in the original transaction will be included in the replacement transaction. The command will fail if the wallet or mempool contains a transaction that spends one of T“s outputs. By default, the new fee will be calculated automatically using the estimatesmartfee RPC. The user can specify a confirmation target for estimatesmartfee. Alternatively, the user can specify a fee rate in sat/vB for the new transaction. At a minimum, the new fee rate must be high enough to pay an additional new relay fee (incrementalfee returned by getnetworkinfo) to enter the node“s mempool.

  • WARNING: before version 0.21, fee_rate was in BTC/kvB. As of 0.21, fee_rate is in sat/vB. *
Source

pub async fn reconsiderblock( &self, blockhash: BlockHash, ) -> Result<(), TransportError>

Removes invalidity status of a block, its ancestors and its descendants, reconsider them for activation. This can be used to undo the effects of invalidateblock.

Source

pub async fn removeprunedfunds(&self, txid: Txid) -> Result<(), TransportError>

Deletes the specified transaction from the wallet. Meant for use with pruned wallets and as a companion to importprunedfunds. This will affect wallet balances.

Source

pub async fn rescanblockchain( &self, start_height: u64, stop_height: u64, ) -> Result<RescanblockchainResponse, TransportError>

Rescan the local blockchain for wallet related transactions. Note: Use “getwalletinfo” to query the scanning progress. The rescan is significantly faster if block filters are available (using startup option “-blockfilterindex=1”).

Source

pub async fn restorewallet( &self, wallet_name: String, backup_file: String, load_on_startup: bool, ) -> Result<RestorewalletResponse, TransportError>

Restores and loads a wallet from backup.

The rescan is significantly faster if block filters are available (using startup option “-blockfilterindex=1”).

Source

pub async fn savemempool(&self) -> Result<SavemempoolResponse, TransportError>

Dumps the mempool to disk. It will fail until the previous dump is fully loaded.

Source

pub async fn scanblocks( &self, action: String, scanobjects: Vec<Value>, start_height: u64, stop_height: u64, filtertype: String, options: Value, ) -> Result<(), TransportError>

Return relevant blockhashes for given descriptors (requires blockfilterindex). This call may take several minutes. Make sure to use no RPC timeout (bitcoin-cli -rpcclienttimeout=0)

Source

pub async fn scantxoutset( &self, action: String, scanobjects: Vec<Value>, ) -> Result<ScantxoutsetResponse, TransportError>

Scans the unspent transaction output set for entries that match certain output descriptors. Examples of output descriptors are: addr(

) Outputs whose output script corresponds to the specified address (does not include P2PK) raw() Outputs whose output script equals the specified hex-encoded bytes combo() P2PK, P2PKH, P2WPKH, and P2SH-P2WPKH outputs for the given pubkey pkh() P2PKH outputs for the given pubkey sh(multi(,,,…)) P2SH-multisig outputs for the given threshold and pubkeys tr() P2TR tr(,{pk()}) P2TR with single fallback pubkey in tapscript rawtr() P2TR with the specified key as output key rather than inner wsh(and_v(v:pk(),after(2))) P2WSH miniscript with mandatory pubkey and a timelock

In the above, either refers to a fixed public key in hexadecimal notation, or to an xpub/xprv optionally followed by one or more path elements separated by “/”, and optionally ending in “/” (unhardened), or “/”“ or “/*h” (hardened) to specify all unhardened or hardened child keys. In the latter case, a range needs to be specified by below if different from 1000. For more information on output descriptors, see the documentation in the doc/descriptors.md file.

Source

pub async fn schema(&self) -> Result<SchemaResponse, TransportError>

Return RPC command JSON Schema descriptions.

Source

pub async fn send( &self, outputs: Vec<Value>, conf_target: u64, estimate_mode: String, fee_rate: f64, options: Value, version: u32, ) -> Result<SendResponse, TransportError>

EXPERIMENTAL warning: this call may be changed in future releases.

Send a transaction.

Source

pub async fn sendall( &self, recipients: Vec<Value>, conf_target: u64, estimate_mode: String, fee_rate: f64, options: Value, ) -> Result<SendallResponse, TransportError>

EXPERIMENTAL warning: this call may be changed in future releases.

Spend the value of all (or specific) confirmed UTXOs and unconfirmed change in the wallet to one or more recipients. Unconfirmed inbound UTXOs and locked UTXOs will not be spent. Sendall will respect the avoid_reuse wallet flag. 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.

Source

pub async fn sendmany( &self, dummy: Option<String>, amounts: Value, minconf: u32, comment: String, subtractfeefrom: Vec<Value>, replaceable: bool, conf_target: u64, estimate_mode: String, fee_rate: f64, verbose: bool, ) -> Result<SendmanyResponse, TransportError>

Send multiple times. Amounts are double-precision floating point numbers. Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.

Source

pub async fn sendmsgtopeer( &self, peer_id: u64, msg_type: String, msg: String, ) -> Result<SendmsgtopeerResponse, TransportError>

Send a p2p message to a peer specified by id. The message type and body must be provided, the message header will be generated. This RPC is for testing only.

Source

pub async fn sendrawtransaction( &self, hexstring: String, maxfeerate: f64, maxburnamount: f64, ) -> Result<SendrawtransactionResponse, TransportError>

Submit a raw transaction (serialized, hex-encoded) to local node and network.

The transaction will be sent unconditionally to all peers, so using sendrawtransaction for manual rebroadcast may degrade privacy by leaking the transaction“s origin, as nodes will normally not rebroadcast non-wallet transactions already in their mempool.

A specific exception, RPC_TRANSACTION_ALREADY_IN_UTXO_SET, may throw if the transaction cannot be added to the mempool.

Related RPCs: createrawtransaction, signrawtransactionwithkey

Source

pub async fn sendtoaddress( &self, address: String, amount: Amount, comment: String, comment_to: String, subtractfeefromamount: bool, replaceable: bool, conf_target: u64, estimate_mode: String, avoid_reuse: bool, fee_rate: f64, verbose: bool, ) -> Result<SendtoaddressResponse, TransportError>

Send an amount to a given address. Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.

Source

pub async fn setban( &self, subnet: String, command: String, bantime: u64, absolute: bool, ) -> Result<(), TransportError>

Attempts to add or remove an IP/Subnet from the banned list.

Source

pub async fn setlabel( &self, address: String, label: String, ) -> Result<(), TransportError>

Sets the label associated with the given address.

Source

pub async fn setmocktime(&self, timestamp: u64) -> Result<(), TransportError>

Set the local time to given timestamp (-regtest only)

Source

pub async fn setnetworkactive( &self, state: bool, ) -> Result<SetnetworkactiveResponse, TransportError>

Disable/enable all p2p network activity.

Source

pub async fn settxfee( &self, amount: Amount, ) -> Result<SettxfeeResponse, TransportError>

(DEPRECATED) Set the transaction fee rate in BTC/kvB for this wallet. Overrides the global -paytxfee command line parameter. Can be deactivated by passing 0 as the fee. In that case automatic fee selection will be used by default.

Source

pub async fn setwalletflag( &self, flag: String, value: bool, ) -> Result<SetwalletflagResponse, TransportError>

Change the state of the given wallet flag for a wallet.

Source

pub async fn signmessage( &self, address: String, message: String, ) -> Result<SignmessageResponse, TransportError>

Sign a message with the private key of an address Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.

Source

pub async fn signmessagewithprivkey( &self, privkey: String, message: String, ) -> Result<SignmessagewithprivkeyResponse, TransportError>

Sign a message with the private key of an address

Source

pub async fn signrawtransactionwithkey( &self, hexstring: String, privkeys: Vec<String>, prevtxs: Vec<Value>, sighashtype: String, ) -> Result<SignrawtransactionwithkeyResponse, TransportError>

Sign inputs for raw transaction (serialized, hex-encoded). The second argument is an array of base58-encoded private keys that will be the only keys used to sign the transaction. The third optional argument (may be null) is an array of previous transaction outputs that this transaction depends on but may not yet be in the block chain.

Source

pub async fn signrawtransactionwithwallet( &self, hexstring: String, prevtxs: Vec<Value>, sighashtype: String, ) -> Result<SignrawtransactionwithwalletResponse, TransportError>

Sign inputs for raw transaction (serialized, hex-encoded). The second optional argument (may be null) is an array of previous transaction outputs that this transaction depends on but may not yet be in the block chain. Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.

Source

pub async fn simulaterawtransaction( &self, rawtxs: Vec<Value>, options: Value, ) -> Result<SimulaterawtransactionResponse, TransportError>

Calculate the balance change resulting in the signing and broadcasting of the given transaction(s).

Source

pub async fn stop(&self, wait: u64) -> Result<StopResponse, TransportError>

Request a graceful shutdown of Bitcoin Core.

Source

pub async fn submitblock( &self, hexdata: String, dummy: Option<String>, ) -> Result<(), TransportError>

Attempts to submit new block to network. See https://en.bitcoin.it/wiki/BIP_0022 for full specification.

Source

pub async fn submitheader(&self, hexdata: String) -> Result<(), TransportError>

Decode the given hexdata as a header and submit it as a candidate chain tip if valid. Throws when the header is invalid.

Source

pub async fn submitpackage( &self, package: Vec<Value>, maxfeerate: f64, maxburnamount: f64, ) -> Result<SubmitpackageResponse, TransportError>

Submit a package of raw transactions (serialized, hex-encoded) to local node. The package will be validated according to consensus and mempool policy rules. If any transaction passes, it will be accepted to mempool. This RPC is experimental and the interface may be unstable. Refer to doc/policy/packages.md for documentation on package policies. Warning: successful submission does not mean the transactions will propagate throughout the network.

Source

pub async fn syncwithvalidationinterfacequeue( &self, ) -> Result<(), TransportError>

Waits for the validation interface queue to catch up on everything that was there when we entered this function.

Source

pub async fn testmempoolaccept( &self, rawtxs: Vec<Value>, maxfeerate: f64, ) -> Result<TestmempoolacceptResponse, TransportError>

Returns result of mempool acceptance tests indicating if raw transaction(s) (serialized, hex-encoded) would be accepted by mempool.

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.

If one transaction fails, other transactions may not be fully validated (the “allowed” key will be blank).

The maximum number of transactions allowed is 25.

This checks if transactions violate the consensus or policy rules.

See sendrawtransaction call.

Source

pub async fn unloadwallet( &self, wallet_name: String, load_on_startup: bool, ) -> Result<UnloadwalletResponse, TransportError>

Unloads the wallet referenced by the request endpoint or the wallet_name argument. If both are specified, they must be identical.

Source

pub async fn uptime(&self) -> Result<UptimeResponse, TransportError>

Returns the total uptime of the server.

Source

pub async fn utxoupdatepsbt( &self, psbt: String, descriptors: Vec<Value>, ) -> Result<UtxoupdatepsbtResponse, TransportError>

Updates all segwit inputs and outputs in a PSBT with data from output descriptors, the UTXO set, txindex, or the mempool.

Source

pub async fn validateaddress( &self, address: String, ) -> Result<ValidateaddressResponse, TransportError>

Return information about the given bitcoin address.

Source

pub async fn verifychain( &self, checklevel: u32, nblocks: u64, ) -> Result<VerifychainResponse, TransportError>

Verifies blockchain database.

Source

pub async fn verifymessage( &self, address: String, signature: String, message: String, ) -> Result<VerifymessageResponse, TransportError>

Verify a signed message.

Source

pub async fn verifytxoutproof( &self, proof: String, ) -> Result<VerifytxoutproofResponse, TransportError>

Verifies that a proof points to a transaction in a block, returning the transaction it commits to and throwing an RPC error if the block is not in our best chain

Source

pub async fn waitforblock( &self, blockhash: BlockHash, timeout: u64, ) -> Result<WaitforblockResponse, TransportError>

Waits for a specific new block and returns useful info about it.

Returns the current block on timeout or exit.

Make sure to use no RPC timeout (bitcoin-cli -rpcclienttimeout=0)

Source

pub async fn waitforblockheight( &self, height: u64, timeout: u64, ) -> Result<WaitforblockheightResponse, TransportError>

Waits for (at least) block height and returns the height and hash of the current tip.

Returns the current block on timeout or exit.

Make sure to use no RPC timeout (bitcoin-cli -rpcclienttimeout=0)

Source

pub async fn waitfornewblock( &self, timeout: u64, current_tip: String, ) -> Result<WaitfornewblockResponse, TransportError>

Waits for any new block and returns useful info about it.

Returns the current block on timeout or exit.

Make sure to use no RPC timeout (bitcoin-cli -rpcclienttimeout=0)

Source

pub async fn walletcreatefundedpsbt( &self, inputs: Vec<Value>, outputs: Vec<Value>, locktime: u32, options: Value, bip32derivs: bool, version: u32, ) -> Result<WalletcreatefundedpsbtResponse, TransportError>

Creates and funds a transaction in the Partially Signed Transaction format. Implements the Creator and Updater roles. All existing inputs must either have their previous output transaction be in the wallet or be in the UTXO set. Solving data must be provided for non-wallet inputs.

Source

pub async fn walletdisplayaddress( &self, address: String, ) -> Result<WalletdisplayaddressResponse, TransportError>

Display address on an external signer for verification.

Source

pub async fn walletlock(&self) -> Result<(), TransportError>

Removes the wallet encryption key from memory, locking the wallet. After calling this method, you will need to call walletpassphrase again before being able to call any methods which require the wallet to be unlocked.

Source

pub async fn walletpassphrase( &self, passphrase: String, timeout: u64, ) -> Result<(), TransportError>

Stores the wallet decryption key in memory for “timeout” seconds. This is needed prior to performing transactions related to private keys such as sending bitcoins

Note: Issuing the walletpassphrase command while the wallet is already unlocked will set a new unlock time that overrides the old one.

Source

pub async fn walletpassphrasechange( &self, oldpassphrase: String, newpassphrase: String, ) -> Result<(), TransportError>

Changes the wallet passphrase from “oldpassphrase” to “newpassphrase”.

Source

pub async fn walletprocesspsbt( &self, psbt: String, sign: bool, sighashtype: String, bip32derivs: bool, finalize: bool, ) -> Result<WalletprocesspsbtResponse, TransportError>

Update a PSBT with input information from our wallet and then sign inputs that we can sign for. Requires wallet passphrase to be set with walletpassphrase call if wallet is encrypted.

Source

pub async fn send_to_address_with_conf_target( &self, address: String, amount: Amount, conf_target: u64, estimate_mode: String, ) -> Result<Value, TransportError>

Helper method to send bitcoin to an address with either a confirmation target or fee rate. This is a more ergonomic wrapper around sendtoaddress that prevents specifying both conf_target and fee_rate.

Parameters:

  • address: The destination address
  • amount: The amount to send
  • conf_target: The confirmation target in blocks
  • estimate_mode: The fee estimate mode (“economical” or “conservative”)
Source

pub async fn send_to_address_with_fee_rate( &self, address: String, amount: Amount, fee_rate: f64, ) -> Result<Value, TransportError>

Trait Implementations§

Source§

impl Debug for BitcoinTestClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for BitcoinTestClient

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,