Struct bitcoincore_rpc::Client 
source · pub struct Client { /* private fields */ }Expand description
Client implements a JSON-RPC client for the Bitcoin Core daemon or compatible APIs.
Implementations
sourceimpl Client
 
impl Client
sourcepub fn new(url: String, user: Option<String>, pass: Option<String>) -> Self
 
pub fn new(url: String, user: Option<String>, pass: Option<String>) -> Self
Creates a client to a bitcoind JSON-RPC server.
sourcepub fn from_jsonrpc(client: Client) -> Client
 
pub fn from_jsonrpc(client: Client) -> Client
Create a new Client.
sourcepub fn get_by_id<T: Queryable>(&mut self, id: &<T as Queryable>::Id) -> Result<T>
 
pub fn get_by_id<T: Queryable>(&mut self, id: &<T as Queryable>::Id) -> Result<T>
Query an object implementing Querable type
sourcepub fn call<T: for<'a> Deserialize<'a>>(
    &mut self,
    cmd: &str,
    args: &[Value]
) -> Result<T>
 
pub fn call<T: for<'a> Deserialize<'a>>(
    &mut self,
    cmd: &str,
    args: &[Value]
) -> Result<T>
Call an cmd rpc with given args list
pub fn add_multisig_address(
    &mut self,
    nrequired: usize,
    keys: Vec<PubKeyOrAddress<'_>>,
    label: Option<&str>,
    address_type: Option<AddressType>
) -> Result<AddMultiSigAddressResult>
pub fn backup_wallet(&mut self, destination: Option<&str>) -> Result<()>
pub fn dump_priv_key(&mut self, address: &Address) -> Result<String>
pub fn encrypt_wallet(&mut self, passphrase: &str) -> Result<()>
pub fn get_difficulty(&mut self) -> Result<BigUint>
pub fn get_connection_count(&mut self) -> Result<usize>
pub fn get_block(&mut self, hash: &Sha256dHash) -> Result<Block>
pub fn get_block_hex(&mut self, hash: &Sha256dHash) -> Result<String>
pub fn get_block_info(&mut self, hash: &Sha256dHash) -> Result<GetBlockResult>
pub fn get_block_header_raw(&mut self, hash: &Sha256dHash) -> Result<BlockHeader>
pub fn get_block_header_verbose(
    &mut self,
    hash: &Sha256dHash
) -> Result<GetBlockHeaderResult>
pub fn get_mining_info(&mut self) -> Result<GetMiningInfoResult>
sourcepub fn get_blockchain_info(&mut self) -> Result<GetBlockchainInfoResult>
 
pub fn get_blockchain_info(&mut self) -> Result<GetBlockchainInfoResult>
Returns a data structure containing various state info regarding blockchain processing.
sourcepub fn get_block_count(&mut self) -> Result<u64>
 
pub fn get_block_count(&mut self) -> Result<u64>
Returns the numbers of block in the longest chain.
sourcepub fn get_best_block_hash(&mut self) -> Result<Sha256dHash>
 
pub fn get_best_block_hash(&mut self) -> Result<Sha256dHash>
Returns the hash of the best (tip) block in the longest blockchain.
sourcepub fn get_block_hash(&mut self, height: u64) -> Result<Sha256dHash>
 
pub fn get_block_hash(&mut self, height: u64) -> Result<Sha256dHash>
Get block hash at a given height
pub fn get_raw_transaction(
    &mut self,
    txid: &Sha256dHash,
    block_hash: Option<&Sha256dHash>
) -> Result<Transaction>
pub fn get_raw_transaction_hex(
    &mut self,
    txid: &Sha256dHash,
    block_hash: Option<&Sha256dHash>
) -> Result<String>
pub fn get_raw_transaction_verbose(
    &mut self,
    txid: &Sha256dHash,
    block_hash: Option<&Sha256dHash>
) -> Result<GetRawTransactionResult>
pub fn get_received_by_address(
    &mut self,
    address: &Address,
    minconf: Option<u32>
) -> Result<Amount>
pub fn get_transaction(
    &mut self,
    txid: &Sha256dHash,
    include_watchonly: Option<bool>
) -> Result<GetTransactionResult>
pub fn get_tx_out(
    &mut self,
    txid: &Sha256dHash,
    vout: u32,
    include_mempool: Option<bool>
) -> Result<Option<GetTxOutResult>>
pub fn import_priv_key(
    &mut self,
    privkey: &str,
    label: Option<&str>,
    rescan: Option<bool>
) -> Result<()>
pub fn key_pool_refill(&mut self, new_size: Option<usize>) -> Result<()>
pub fn list_unspent(
    &mut self,
    minconf: Option<usize>,
    maxconf: Option<usize>,
    addresses: Option<Vec<&Address>>,
    include_unsafe: Option<bool>,
    query_options: Option<HashMap<&str, &str>>
) -> Result<Vec<ListUnspentResult>>
pub fn sign_raw_transaction(
    &mut self,
    tx: HexBytes<'_>,
    utxos: Option<&[UTXO<'_>]>,
    private_keys: Option<&[&str]>,
    sighash_type: Option<SigHashType>
) -> Result<SignRawTransactionResult>
pub fn stop(&mut self) -> Result<()>
pub fn sign_raw_transaction_with_wallet(
    &mut self,
    tx: HexBytes<'_>,
    utxos: Option<&[UTXO<'_>]>,
    sighash_type: Option<SigHashType>
) -> Result<SignRawTransactionResult>
pub fn verify_message(
    &mut self,
    address: &Address,
    signature: &Signature,
    message: &str
) -> Result<bool>
sourcepub fn get_new_address(&mut self, account: &str) -> Result<String>
 
pub fn get_new_address(&mut self, account: &str) -> Result<String>
Generate new address under own control
sourcepub fn generate_to_address(
    &mut self,
    block_num: u64,
    address: &str
) -> Result<Vec<Sha256dHash>>
 
pub fn generate_to_address(
    &mut self,
    block_num: u64,
    address: &str
) -> Result<Vec<Sha256dHash>>
Mine block_num blocks and pay coinbase to address
Returns hashes of the generated blocks
sourcepub fn invalidate_block(&mut self, block_hash: &Sha256dHash) -> Result<()>
 
pub fn invalidate_block(&mut self, block_hash: &Sha256dHash) -> Result<()>
Mark a block as invalid by block_hash
sourcepub fn get_peer_info(&mut self) -> Result<Vec<GetPeerInfoResult>>
 
pub fn get_peer_info(&mut self) -> Result<Vec<GetPeerInfoResult>>
Returns data about each connected network node as an array of
PeerInfo
sourcepub fn ping(&mut self) -> Result<()>
 
pub fn ping(&mut self) -> Result<()>
Requests that a ping be sent to all other nodes, to measure ping time.
Results provided in getpeerinfo, pingtime and pingwait fields
are decimal seconds.
Ping command is handled in queue with all other commands, so it measures processing backlog, not just network ping.
pub fn send_raw_transaction(&mut self, tx: &str) -> Result<String>
pub fn estimate_smartfee<E>(
    &mut self,
    conf_target: u16,
    estimate_mode: Option<EstimateMode>
) -> Result<EstimateSmartFeeResult>
sourcepub fn wait_for_new_block(&mut self, timeout: u64) -> Result<BlockRef>
 
pub fn wait_for_new_block(&mut self, timeout: u64) -> Result<BlockRef>
Waits for a specific new block and returns useful info about it. Returns the current block on timeout or exit.
Arguments
- timeout: Time in milliseconds to wait for a response. 0 indicates no timeout.
sourcepub fn wait_for_block(
    &mut self,
    blockhash: &Sha256dHash,
    timeout: u64
) -> Result<BlockRef>
 
pub fn wait_for_block(
    &mut self,
    blockhash: &Sha256dHash,
    timeout: u64
) -> Result<BlockRef>
Waits for a specific new block and returns useful info about it. Returns the current block on timeout or exit.
Arguments
- blockhash: Block hash to wait for.
- timeout: Time in milliseconds to wait for a response. 0 indicates no timeout.