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<()>
pub fn check_expected_server_version(&self) -> Result<()>
Checks that the JSON-RPC endpoint is for a bitcoind
instance with the expected version.
Source§impl Client
impl Client
Sourcepub fn best_block_hash(&self) -> Result<BlockHash>
pub fn best_block_hash(&self) -> Result<BlockHash>
Gets the blockhash of the current chain tip.
pub fn get_best_block_hash(&self) -> Result<GetBestBlockHash>
Source§impl Client
impl Client
Sourcepub fn get_block_verbose_zero(
&self,
hash: BlockHash,
) -> Result<GetBlockVerboseZero>
pub fn get_block_verbose_zero( &self, hash: BlockHash, ) -> Result<GetBlockVerboseZero>
Gets a block by blockhash with verbose set to 0.
Sourcepub fn get_block_verbose_one(
&self,
hash: BlockHash,
) -> Result<GetBlockVerboseOne>
pub fn get_block_verbose_one( &self, hash: BlockHash, ) -> Result<GetBlockVerboseOne>
Gets a block by blockhash with verbose set to 1.
Source§impl Client
impl Client
pub fn get_blockchain_info(&self) -> Result<GetBlockchainInfo>
Source§impl Client
impl Client
pub fn get_block_count(&self) -> Result<GetBlockCount>
Source§impl Client
impl Client
pub fn get_block_filter(&self, block: BlockHash) -> Result<GetBlockFilter>
Source§impl Client
impl Client
pub fn get_block_hash(&self, height: u64) -> Result<GetBlockHash>
Source§impl Client
impl Client
pub fn get_block_header(&self, hash: &BlockHash) -> Result<GetBlockHeader>
pub fn get_block_header_verbose( &self, hash: &BlockHash, ) -> Result<GetBlockHeaderVerbose>
Source§impl Client
impl Client
pub fn get_block_stats_by_height(&self, height: u32) -> Result<GetBlockStats>
pub fn get_block_stats_by_block_hash( &self, hash: &BlockHash, ) -> Result<GetBlockStats>
Source§impl Client
impl Client
pub fn get_chain_tips(&self) -> Result<GetChainTips>
Source§impl Client
impl Client
pub fn get_chain_tx_stats(&self) -> Result<GetChainTxStats>
Source§impl Client
impl Client
pub fn get_difficulty(&self) -> Result<GetDifficulty>
Source§impl Client
impl Client
pub fn get_mempool_ancestors(&self, txid: Txid) -> Result<GetMempoolAncestors>
pub fn get_mempool_ancestors_verbose( &self, txid: Txid, ) -> Result<GetMempoolAncestorsVerbose>
Source§impl Client
impl Client
pub fn get_mempool_descendants( &self, txid: Txid, ) -> Result<GetMempoolDescendants>
pub fn get_mempool_descendants_verbose( &self, txid: Txid, ) -> Result<GetMempoolDescendantsVerbose>
Source§impl Client
impl Client
pub fn get_mempool_entry(&self, txid: Txid) -> Result<GetMempoolEntry>
Source§impl Client
impl Client
pub fn get_mempool_info(&self) -> Result<GetMempoolInfo>
Source§impl Client
impl Client
pub fn get_raw_mempool(&self) -> Result<GetRawMempool>
pub fn get_raw_mempool_verbose(&self) -> Result<GetRawMempool>
Source§impl Client
impl Client
pub fn get_tx_out_set_info(&self) -> Result<GetTxOutSetInfo>
Source§impl Client
impl Client
Sourcepub fn prune_blockchain(&self, target: u64) -> Result<PruneBlockchain>
pub fn prune_blockchain(&self, target: u64) -> Result<PruneBlockchain>
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>
Source§impl Client
impl Client
pub fn verify_chain(&self) -> Result<VerifyChain>
Source§impl Client
impl Client
pub fn verify_tx_out_proof(&self, proof: &str) -> Result<VerifyTxOutProof>
Source§impl Client
impl Client
pub fn get_memory_info(&self) -> Result<GetMemoryInfoStats>
Source§impl Client
impl Client
pub fn get_rpc_info(&self) -> Result<GetRpcInfo>
Source§impl Client
impl Client
pub fn generate_to_address( &self, nblocks: usize, address: &Address, ) -> Result<GenerateToAddress>
Source§impl Client
impl Client
pub fn get_block_template( &self, request: &TemplateRequest, ) -> Result<GetBlockTemplate>
Source§impl Client
impl Client
pub fn get_mining_info(&self) -> Result<GetMiningInfo>
Source§impl Client
impl Client
pub fn prioritise_transaction( &self, txid: &Txid, fee_delta: SignedAmount, ) -> Result<bool>
Source§impl Client
impl Client
pub fn get_added_node_info(&self) -> Result<GetAddedNodeInfo>
Source§impl Client
impl Client
pub fn get_net_totals(&self) -> Result<GetNetTotals>
Source§impl Client
impl Client
Sourcepub fn server_version(&self) -> Result<usize>
pub fn server_version(&self) -> Result<usize>
Returns the server version field of GetNetworkInfo
.
pub fn get_network_info(&self) -> Result<GetNetworkInfo>
Source§impl Client
impl Client
pub fn get_node_addresses(&self) -> Result<GetNodeAddresses>
Source§impl Client
impl Client
pub fn get_peer_info(&self) -> Result<GetPeerInfo>
Source§impl Client
impl Client
pub fn analyze_psbt(&self, psbt: &Psbt) -> Result<AnalyzePsbt>
Source§impl Client
impl Client
pub fn combine_psbt(&self, txs: &[Psbt]) -> Result<CombinePsbt>
Source§impl Client
impl Client
pub fn combine_raw_transaction( &self, txs: &[Transaction], ) -> Result<CombineRawTransaction>
Source§impl Client
impl Client
pub fn convert_to_psbt(&self, tx: &Transaction) -> Result<ConvertToPsbt>
Source§impl Client
impl Client
pub fn create_psbt( &self, inputs: &[Input], outputs: &[Output], ) -> Result<CreatePsbt>
Source§impl Client
impl Client
pub fn create_raw_transaction( &self, inputs: &[Input], outputs: &[Output], ) -> Result<CreateRawTransaction>
Source§impl Client
impl Client
pub fn decode_psbt(&self, psbt: &str) -> Result<DecodePsbt>
Source§impl Client
impl Client
pub fn decode_raw_transaction( &self, tx: &Transaction, ) -> Result<DecodeRawTransaction>
Source§impl Client
impl Client
pub fn decode_script(&self, script: &str) -> Result<DecodeScript>
Source§impl Client
impl Client
pub fn finalize_psbt(&self, psbt: &Psbt) -> Result<FinalizePsbt>
Source§impl Client
impl Client
pub fn fund_raw_transaction( &self, tx: &Transaction, ) -> Result<FundRawTransaction>
Source§impl Client
impl Client
pub fn get_raw_transaction(&self, txid: Txid) -> Result<GetRawTransaction>
pub fn get_raw_transaction_verbose( &self, txid: Txid, ) -> Result<GetRawTransactionVerbose>
Source§impl Client
impl Client
pub fn send_raw_transaction( &self, tx: &Transaction, ) -> Result<SendRawTransaction>
Source§impl Client
impl Client
pub fn sign_raw_transaction( &self, tx: &Transaction, ) -> Result<SignRawTransaction>
Source§impl Client
impl Client
pub fn sign_raw_transaction_with_key( &self, tx: &Transaction, keys: &[PrivateKey], ) -> Result<SignRawTransaction>
Source§impl Client
impl Client
pub fn test_mempool_accept( &self, txs: &[Transaction], ) -> Result<TestMempoolAccept>
Source§impl Client
impl Client
pub fn create_multisig( &self, nrequired: u32, keys: Vec<PublicKey>, ) -> Result<CreateMultisig>
Source§impl Client
impl Client
pub fn estimate_smart_fee(&self, blocks: u32) -> Result<EstimateSmartFee>
Source§impl Client
impl Client
pub fn sign_message_with_privkey( &self, privkey: &PrivateKey, message: &str, ) -> Result<SignMessageWithPrivKey>
Source§impl Client
impl Client
pub fn validate_address( &self, address: &Address<NetworkChecked>, ) -> Result<ValidateAddress>
Source§impl Client
impl Client
pub fn verify_message( &self, address: &Address<NetworkChecked>, signature: &MessageSignature, message: &str, ) -> Result<VerifyMessage>
Source§impl Client
impl Client
pub fn add_multisig_address_with_keys( &self, nrequired: u32, keys: Vec<PublicKey>, ) -> Result<AddMultisigAddress>
pub fn add_multisig_address_with_addresses( &self, nrequired: u32, keys: Vec<Address>, ) -> Result<AddMultisigAddress>
Source§impl Client
impl Client
Sourcepub fn create_wallet(&self, wallet: &str) -> Result<CreateWallet>
pub fn create_wallet(&self, wallet: &str) -> Result<CreateWallet>
Calls createwallet
with wallet
as the only argument.
Sourcepub fn create_legacy_wallet(&self, wallet: &str) -> Result<CreateWallet>
pub fn create_legacy_wallet(&self, wallet: &str) -> Result<CreateWallet>
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 dump_priv_key(&self, address: &Address) -> Result<DumpPrivKey>
Source§impl Client
impl Client
pub fn dump_wallet(&self, filename: &Path) -> Result<DumpWallet>
Source§impl Client
impl Client
pub fn get_addresses_by_label(&self, label: &str) -> Result<GetAddressesByLabel>
Source§impl Client
impl Client
pub fn get_address_info(&self, address: &Address) -> Result<GetAddressInfo>
Source§impl Client
impl Client
pub fn get_balance(&self) -> Result<GetBalance>
Source§impl Client
impl Client
pub fn get_balances(&self) -> Result<GetBalances>
Source§impl Client
impl Client
Sourcepub fn new_address(&self) -> Result<Address>
pub fn new_address(&self) -> Result<Address>
Gets a new address from bitcoind
and parses it assuming its correct.
Sourcepub fn new_address_with_type(&self, ty: AddressType) -> Result<Address>
pub fn new_address_with_type(&self, ty: AddressType) -> Result<Address>
Gets a new address from bitcoind
and parses it assuming its correct.
Sourcepub fn new_address_with_label(
&self,
label: &str,
) -> Result<Address<NetworkUnchecked>>
pub fn new_address_with_label( &self, label: &str, ) -> Result<Address<NetworkUnchecked>>
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>
pub fn get_new_address( &self, label: Option<&str>, ty: Option<AddressType>, ) -> Result<GetNewAddress>
Gets a new address - low level RPC call.