pub struct Client { /* private fields */ }Expand description
Client implements a JSON-RPC client for the Bitcoin Core daemon or compatible APIs.
Implementations§
Source§impl Client
impl Client
Source§impl Client
impl Client
Sourcepub fn check_expected_server_version(&self) -> Result<(), Error>
pub fn check_expected_server_version(&self) -> Result<(), Error>
Checks that the JSON-RPC endpoint is for a bitcoind instance with the expected version.
Source§impl Client
impl Client
pub fn dump_tx_out_set(&self, path: &str) -> Result<DumpTxOutSet, Error>
Source§impl Client
impl Client
Sourcepub fn best_block_hash(&self) -> Result<BlockHash, Error>
pub fn best_block_hash(&self) -> Result<BlockHash, Error>
Gets the blockhash of the current chain tip.
pub fn get_best_block_hash(&self) -> Result<GetBestBlockHash, Error>
Source§impl Client
impl Client
Sourcepub fn get_block_verbose_zero(
&self,
hash: BlockHash,
) -> Result<GetBlockVerboseZero, Error>
pub fn get_block_verbose_zero( &self, hash: BlockHash, ) -> Result<GetBlockVerboseZero, Error>
Gets a block by blockhash with verbose set to 0.
Sourcepub fn get_block_verbose_one(
&self,
hash: BlockHash,
) -> Result<GetBlockVerboseOne, Error>
pub fn get_block_verbose_one( &self, hash: BlockHash, ) -> Result<GetBlockVerboseOne, Error>
Gets a block by blockhash with verbose set to 1.
Source§impl Client
impl Client
pub fn get_blockchain_info(&self) -> Result<GetBlockchainInfo, Error>
Source§impl Client
impl Client
pub fn get_block_count(&self) -> Result<GetBlockCount, Error>
Source§impl Client
impl Client
pub fn get_block_filter( &self, block: BlockHash, ) -> Result<GetBlockFilter, Error>
Source§impl Client
impl Client
pub fn get_block_hash(&self, height: u64) -> Result<GetBlockHash, Error>
Source§impl Client
impl Client
pub fn get_block_header( &self, hash: &BlockHash, ) -> Result<GetBlockHeader, Error>
pub fn get_block_header_verbose( &self, hash: &BlockHash, ) -> Result<GetBlockHeaderVerbose, Error>
Source§impl Client
impl Client
pub fn get_block_stats_by_height( &self, height: u32, ) -> Result<GetBlockStats, Error>
pub fn get_block_stats_by_block_hash( &self, hash: &BlockHash, ) -> Result<GetBlockStats, Error>
Source§impl Client
impl Client
pub fn get_chain_states(&self) -> Result<GetChainStates, Error>
Source§impl Client
impl Client
pub fn get_chain_tips(&self) -> Result<GetChainTips, Error>
Source§impl Client
impl Client
pub fn get_chain_tx_stats(&self) -> Result<GetChainTxStats, Error>
Source§impl Client
impl Client
pub fn get_deployment_info( &self, blockhash: &BlockHash, ) -> Result<GetDeploymentInfo, Error>
Source§impl Client
impl Client
pub fn get_difficulty(&self) -> Result<GetDifficulty, Error>
Source§impl Client
impl Client
pub fn get_mempool_ancestors( &self, txid: Txid, ) -> Result<GetMempoolAncestors, Error>
pub fn get_mempool_ancestors_verbose( &self, txid: Txid, ) -> Result<GetMempoolAncestorsVerbose, Error>
Source§impl Client
impl Client
pub fn get_mempool_descendants( &self, txid: Txid, ) -> Result<GetMempoolDescendants, Error>
pub fn get_mempool_descendants_verbose( &self, txid: Txid, ) -> Result<GetMempoolDescendantsVerbose, Error>
Source§impl Client
impl Client
pub fn get_mempool_entry(&self, txid: Txid) -> Result<GetMempoolEntry, Error>
Source§impl Client
impl Client
pub fn get_mempool_info(&self) -> Result<GetMempoolInfo, Error>
Source§impl Client
impl Client
pub fn get_raw_mempool(&self) -> Result<GetRawMempool, Error>
pub fn get_raw_mempool_verbose(&self) -> Result<GetRawMempool, Error>
Source§impl Client
impl Client
pub fn get_tx_out_set_info(&self) -> Result<GetTxOutSetInfo, Error>
Source§impl Client
impl Client
pub fn get_tx_spending_prevout( &self, outputs: &[OutPoint], ) -> Result<GetTxSpendingPrevout, Error>
Source§impl Client
impl Client
Sourcepub fn prune_blockchain(&self, target: u64) -> Result<PruneBlockchain, Error>
pub fn prune_blockchain(&self, target: u64) -> Result<PruneBlockchain, Error>
Instructs the node to prune the blockchain up to a specified height or timestamp.
Source§impl Client
impl Client
pub fn save_mempool(&self) -> Result<SaveMempool, Error>
Source§impl Client
impl Client
Sourcepub fn scan_blocks_abort(&self) -> Result<ScanBlocksAbort, Error>
pub fn scan_blocks_abort(&self) -> Result<ScanBlocksAbort, Error>
Aborts an ongoing scanblocks scan.
Sourcepub fn scan_blocks_start(
&self,
scan_objects: &[&str],
) -> Result<ScanBlocksStart, Error>
pub fn scan_blocks_start( &self, scan_objects: &[&str], ) -> Result<ScanBlocksStart, Error>
Starts a scan of blocks for specified descriptors.
Sourcepub fn scan_blocks_status(&self) -> Result<Option<ScanBlocksStatus>, Error>
pub fn scan_blocks_status(&self) -> Result<Option<ScanBlocksStatus>, Error>
Checks the status of an ongoing scanblocks scan.
Source§impl Client
impl Client
pub fn verify_chain(&self) -> Result<VerifyChain, Error>
Source§impl Client
impl Client
pub fn verify_tx_out_proof( &self, proof: &str, ) -> Result<VerifyTxOutProof, Error>
Source§impl Client
impl Client
pub fn get_memory_info(&self) -> Result<GetMemoryInfoStats, Error>
Source§impl Client
impl Client
pub fn get_rpc_info(&self) -> Result<GetRpcInfo, Error>
Source§impl Client
impl Client
pub fn generate_block( &self, output: &str, transactions: &[String], submit: bool, ) -> Result<GenerateBlock, Error>
Source§impl Client
impl Client
pub fn generate_to_address( &self, nblocks: usize, address: &Address, ) -> Result<GenerateToAddress, Error>
Source§impl Client
impl Client
pub fn generate_to_descriptor( &self, nblocks: usize, descriptor: &str, ) -> Result<GenerateToDescriptor, Error>
Source§impl Client
impl Client
pub fn add_peer_address( &self, address: &str, port: u16, ) -> Result<AddPeerAddress, Error>
Source§impl Client
impl Client
pub fn get_block_template( &self, request: &TemplateRequest, ) -> Result<GetBlockTemplate, Error>
Source§impl Client
impl Client
pub fn get_mining_info(&self) -> Result<GetMiningInfo, Error>
Source§impl Client
impl Client
pub fn get_prioritised_transactions( &self, ) -> Result<GetPrioritisedTransactions, Error>
Source§impl Client
impl Client
pub fn prioritise_transaction( &self, txid: &Txid, fee_delta: SignedAmount, ) -> Result<bool, Error>
Source§impl Client
impl Client
pub fn get_added_node_info(&self) -> Result<GetAddedNodeInfo, Error>
Source§impl Client
impl Client
pub fn get_addr_man_info(&self) -> Result<GetAddrManInfo, Error>
Source§impl Client
impl Client
pub fn get_connection_count(&self) -> Result<GetConnectionCount, Error>
Source§impl Client
impl Client
pub fn get_net_totals(&self) -> Result<GetNetTotals, Error>
Source§impl Client
impl Client
Sourcepub fn server_version(&self) -> Result<usize, Error>
pub fn server_version(&self) -> Result<usize, Error>
Returns the server version field of GetNetworkInfo.
pub fn get_network_info(&self) -> Result<GetNetworkInfo, Error>
Source§impl Client
impl Client
pub fn get_node_addresses(&self) -> Result<GetNodeAddresses, Error>
Source§impl Client
impl Client
pub fn get_peer_info(&self) -> Result<GetPeerInfo, Error>
Source§impl Client
impl Client
pub fn list_banned(&self) -> Result<ListBanned, Error>
Source§impl Client
impl Client
pub fn set_network_active(&self, state: bool) -> Result<SetNetworkActive, Error>
Source§impl Client
impl Client
pub fn analyze_psbt(&self, psbt: &Psbt) -> Result<AnalyzePsbt, Error>
Source§impl Client
impl Client
pub fn combine_psbt(&self, txs: &[Psbt]) -> Result<CombinePsbt, Error>
Source§impl Client
impl Client
pub fn combine_raw_transaction( &self, txs: &[Transaction], ) -> Result<CombineRawTransaction, Error>
Source§impl Client
impl Client
pub fn convert_to_psbt(&self, tx: &Transaction) -> Result<ConvertToPsbt, Error>
Source§impl Client
impl Client
pub fn create_psbt( &self, inputs: &[Input], outputs: &[Output], ) -> Result<CreatePsbt, Error>
Source§impl Client
impl Client
pub fn create_raw_transaction( &self, inputs: &[Input], outputs: &[Output], ) -> Result<CreateRawTransaction, Error>
Source§impl Client
impl Client
pub fn decode_psbt(&self, psbt: &str) -> Result<DecodePsbt, Error>
Source§impl Client
impl Client
pub fn decode_raw_transaction( &self, tx: &Transaction, ) -> Result<DecodeRawTransaction, Error>
Source§impl Client
impl Client
pub fn decode_script(&self, script: &str) -> Result<DecodeScript, Error>
Source§impl Client
impl Client
pub fn finalize_psbt(&self, psbt: &Psbt) -> Result<FinalizePsbt, Error>
Source§impl Client
impl Client
pub fn fund_raw_transaction( &self, tx: &Transaction, ) -> Result<FundRawTransaction, Error>
Source§impl Client
impl Client
pub fn get_raw_transaction( &self, txid: Txid, ) -> Result<GetRawTransaction, Error>
pub fn get_raw_transaction_verbose( &self, txid: Txid, ) -> Result<GetRawTransactionVerbose, Error>
Source§impl Client
impl Client
pub fn send_raw_transaction( &self, tx: &Transaction, ) -> Result<SendRawTransaction, Error>
Source§impl Client
impl Client
pub fn sign_raw_transaction( &self, tx: &Transaction, ) -> Result<SignRawTransaction, Error>
Source§impl Client
impl Client
pub fn sign_raw_transaction_with_key( &self, tx: &Transaction, keys: &[PrivateKey], ) -> Result<SignRawTransaction, Error>
Source§impl Client
impl Client
pub fn submit_package( &self, package: &[Transaction], max_fee_rate: Option<FeeRate>, max_burn_amount: Option<Amount>, ) -> Result<SubmitPackage, Error>
Source§impl Client
impl Client
pub fn test_mempool_accept( &self, txs: &[Transaction], ) -> Result<TestMempoolAccept, Error>
Source§impl Client
impl Client
pub fn utxo_update_psbt(&self, psbt: &Psbt) -> Result<UtxoUpdatePsbt, Error>
Source§impl Client
impl Client
pub fn enumerate_signers(&self) -> Result<EnumerateSigners, Error>
Source§impl Client
impl Client
pub fn create_multisig( &self, nrequired: u32, keys: Vec<PublicKey>, ) -> Result<CreateMultisig, Error>
Source§impl Client
impl Client
pub fn derive_addresses( &self, descriptor: &str, ) -> Result<DeriveAddresses, Error>
Source§impl Client
impl Client
pub fn estimate_smart_fee(&self, blocks: u32) -> Result<EstimateSmartFee, Error>
Source§impl Client
impl Client
pub fn get_descriptor_info( &self, descriptor: &str, ) -> Result<GetDescriptorInfo, Error>
Source§impl Client
impl Client
pub fn get_index_info(&self) -> Result<GetIndexInfo, Error>
Source§impl Client
impl Client
pub fn sign_message_with_privkey( &self, privkey: &PrivateKey, message: &str, ) -> Result<SignMessageWithPrivKey, Error>
Source§impl Client
impl Client
pub fn validate_address( &self, address: &Address, ) -> Result<ValidateAddress, Error>
Source§impl Client
impl Client
pub fn verify_message( &self, address: &Address, signature: &MessageSignature, message: &str, ) -> Result<VerifyMessage, Error>
Source§impl Client
impl Client
pub fn abort_rescan(&self) -> Result<AbortRescan, Error>
Source§impl Client
impl Client
pub fn add_multisig_address_with_keys( &self, nrequired: u32, keys: Vec<PublicKey>, ) -> Result<AddMultisigAddress, Error>
pub fn add_multisig_address_with_addresses( &self, nrequired: u32, keys: Vec<Address>, ) -> Result<AddMultisigAddress, Error>
Source§impl Client
impl Client
Sourcepub fn create_wallet(&self, wallet: &str) -> Result<CreateWallet, Error>
pub fn create_wallet(&self, wallet: &str) -> Result<CreateWallet, Error>
Calls createwallet with wallet as the only argument.
In v23 and later this creates a descriptor wallet. Use create_legacy_wallet to create
a legacy wallet.
Sourcepub fn create_legacy_wallet(&self, wallet: &str) -> Result<CreateWallet, Error>
pub fn create_legacy_wallet(&self, wallet: &str) -> Result<CreateWallet, Error>
Creates a legacy wallet (i.e not a native descriptor wallet).
createwallet “wallet_name” ( disable_private_keys blank “passphrase” avoid_reuse descriptors load_on_startup external_signer )
Creates and loads a new wallet.
Arguments:
- wallet_name (string, required) The name for the new wallet. If this is a path, the wallet will be created at the path location.
- disable_private_keys (boolean, optional, default=false) Disable the possibility of private keys (only watchonlys are possible in this mode).
- blank (boolean, optional, default=false) Create a blank wallet. A blank wallet has no keys or HD seed. One can be set using sethdseed.
- passphrase (string, optional) Encrypt the wallet with this passphrase.
- avoid_reuse (boolean, optional, default=false) Keep track of coin reuse, and treat dirty and clean coins differently with privacy considerations in mind.
- descriptors (boolean, optional, default=true) Create a native descriptor wallet. The wallet will use descriptors internally to handle address creation
- load_on_startup (boolean, optional) Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged.
- external_signer (boolean, optional, default=false) Use an external signer such as a hardware wallet. Requires -signer to be configured. Wallet creation will fail if keys cannot be fetched. Requires disable_private_keys and descriptors set to true.
Source§impl Client
impl Client
pub fn create_wallet_descriptor( &self, address_type: &str, hdkey: &str, ) -> Result<CreateWalletDescriptor, Error>
Source§impl Client
impl Client
pub fn dump_priv_key(&self, address: &Address) -> Result<DumpPrivKey, Error>
Source§impl Client
impl Client
pub fn dump_wallet(&self, filename: &Path) -> Result<DumpWallet, Error>
Source§impl Client
impl Client
pub fn encrypt_wallet(&self, passphrase: &str) -> Result<EncryptWallet, Error>
Source§impl Client
impl Client
pub fn get_addresses_by_label( &self, label: &str, ) -> Result<GetAddressesByLabel, Error>
Source§impl Client
impl Client
pub fn get_address_info( &self, address: &Address, ) -> Result<GetAddressInfo, Error>
Source§impl Client
impl Client
pub fn get_balance(&self) -> Result<GetBalance, Error>
Source§impl Client
impl Client
pub fn get_balances(&self) -> Result<GetBalances, Error>
Source§impl Client
impl Client
pub fn get_received_by_label( &self, label: &str, ) -> Result<GetReceivedByLabel, Error>
Source§impl Client
impl Client
Sourcepub fn new_address(&self) -> Result<Address, Error>
pub fn new_address(&self) -> Result<Address, Error>
Gets a new address from bitcoind and parses it assuming its correct.
Sourcepub fn new_address_with_type(&self, ty: AddressType) -> Result<Address, Error>
pub fn new_address_with_type(&self, ty: AddressType) -> Result<Address, Error>
Gets a new address from bitcoind and parses it assuming its correct.
Sourcepub fn new_address_with_label(
&self,
label: &str,
) -> Result<Address<NetworkUnchecked>, Error>
pub fn new_address_with_label( &self, label: &str, ) -> Result<Address<NetworkUnchecked>, Error>
Gets a new address with label from bitcoind and parses it assuming its correct.
Sourcepub fn get_new_address(
&self,
label: Option<&str>,
ty: Option<AddressType>,
) -> Result<GetNewAddress, Error>
pub fn get_new_address( &self, label: Option<&str>, ty: Option<AddressType>, ) -> Result<GetNewAddress, Error>
Gets a new address - low level RPC call.
Source§impl Client
impl Client
pub fn get_raw_change_address(&self) -> Result<GetRawChangeAddress, Error>
Source§impl Client
impl Client
pub fn get_received_by_address( &self, address: &Address, ) -> Result<GetReceivedByAddress, Error>
Source§impl Client
impl Client
pub fn get_transaction(&self, txid: Txid) -> Result<GetTransaction, Error>
Source§impl Client
impl Client
pub fn get_unconfirmed_balance(&self) -> Result<GetUnconfirmedBalance, Error>
Source§impl Client
impl Client
pub fn get_wallet_info(&self) -> Result<GetWalletInfo, Error>
Source§impl Client
impl Client
pub fn import_descriptors( &self, requests: &[ImportDescriptorsRequest], ) -> Result<ImportDescriptors, Error>
Source§impl Client
impl Client
pub fn import_multi( &self, requests: &[ImportMultiRequest], ) -> Result<ImportMulti, Error>
Source§impl Client
impl Client
pub fn import_privkey(&self, privkey: &PrivateKey) -> Result<(), Error>
Source§impl Client
impl Client
pub fn list_address_groupings(&self) -> Result<ListAddressGroupings, Error>
Source§impl Client
impl Client
pub fn list_descriptors(&self) -> Result<ListDescriptors, Error>
Source§impl Client
impl Client
pub fn list_received_by_label(&self) -> Result<ListReceivedByLabel, Error>
Source§impl Client
impl Client
pub fn list_labels(&self) -> Result<ListLabels, Error>
Source§impl Client
impl Client
pub fn list_lock_unspent(&self) -> Result<ListLockUnspent, Error>
Source§impl Client
impl Client
pub fn list_received_by_address(&self) -> Result<ListReceivedByAddress, Error>
Source§impl Client
impl Client
pub fn list_since_block(&self) -> Result<ListSinceBlock, Error>
Source§impl Client
impl Client
pub fn list_transactions(&self) -> Result<ListTransactions, Error>
Source§impl Client
impl Client
pub fn list_unspent(&self) -> Result<ListUnspent, Error>
Source§impl Client
impl Client
pub fn list_wallet_dir(&self) -> Result<ListWalletDir, Error>
Source§impl Client
impl Client
pub fn list_wallets(&self) -> Result<ListWallets, Error>
Source§impl Client
impl Client
pub fn load_wallet(&self, wallet: &str) -> Result<LoadWallet, Error>
Source§impl Client
impl Client
Sourcepub fn lock_unspent(
&self,
outputs: &[(Txid, u32)],
) -> Result<LockUnspent, Error>
pub fn lock_unspent( &self, outputs: &[(Txid, u32)], ) -> Result<LockUnspent, Error>
Lock the given list of transaction outputs. Returns true on success.
This wraps Core RPC: lockunspent false [{"txid":"..","vout":n},...].
Sourcepub fn unlock_unspent(
&self,
outputs: &[(Txid, u32)],
) -> Result<LockUnspent, Error>
pub fn unlock_unspent( &self, outputs: &[(Txid, u32)], ) -> Result<LockUnspent, Error>
Unlock the given list of transaction outputs. Returns true on success.
This wraps Core RPC: lockunspent true [{"txid":"..","vout":n},...].
Source§impl Client
impl Client
pub fn migrate_wallet(&self, wallet_name: &str) -> Result<MigrateWallet, Error>
Source§impl Client
impl Client
Sourcepub fn new_keypool(&self) -> Result<(), Error>
pub fn new_keypool(&self) -> Result<(), Error>
Calls newkeypool for the loaded wallet.
newkeypool
Entirely clears and refills the keypool. Requires wallet passphrase to be set if wallet is encrypted.
Source§impl Client
impl Client
pub fn psbt_bump_fee(&self, txid: &Txid) -> Result<PsbtBumpFee, Error>
Source§impl Client
impl Client
pub fn rescan_blockchain(&self) -> Result<RescanBlockchain, Error>
Source§impl Client
impl Client
Sourcepub fn restore_wallet(
&self,
wallet_name: &str,
backup_file: &Path,
) -> Result<RestoreWallet, Error>
pub fn restore_wallet( &self, wallet_name: &str, backup_file: &Path, ) -> Result<RestoreWallet, Error>
Calls restorewallet with required and optional arguments.
restorewallet “wallet_name” “backup_file” ( load_on_startup )