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 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_block( &self, output: &str, transactions: &[String], ) -> Result<GenerateBlock>
Source§impl Client
impl Client
pub fn generate_to_address( &self, nblocks: usize, address: &Address, ) -> Result<GenerateToAddress>
Source§impl Client
impl Client
pub fn generate_to_descriptor( &self, nblocks: usize, descriptor: &str, ) -> Result<GenerateToDescriptor>
Source§impl Client
impl Client
pub fn add_peer_address( &self, address: &str, port: u16, ) -> Result<AddPeerAddress>
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_connection_count(&self) -> Result<GetConnectionCount>
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 list_banned(&self) -> Result<ListBanned>
Source§impl Client
impl Client
pub fn set_network_active(&self, state: bool) -> Result<SetNetworkActive>
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<SignRawTransactionWithKey>
Source§impl Client
impl Client
pub fn test_mempool_accept( &self, txs: &[Transaction], ) -> Result<TestMempoolAccept>
Source§impl Client
impl Client
pub fn utxo_update_psbt(&self, psbt: &Psbt) -> Result<UtxoUpdatePsbt>
Source§impl Client
impl Client
pub fn create_multisig( &self, nrequired: u32, keys: Vec<PublicKey>, ) -> Result<CreateMultisig>
Source§impl Client
impl Client
pub fn derive_addresses(&self, descriptor: &str) -> Result<DeriveAddresses>
Source§impl Client
impl Client
pub fn estimate_smart_fee(&self, blocks: u32) -> Result<EstimateSmartFee>
Source§impl Client
impl Client
pub fn get_descriptor_info(&self, descriptor: &str) -> Result<GetDescriptorInfo>
Source§impl Client
impl Client
pub fn get_index_info(&self) -> Result<GetIndexInfo>
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 abort_rescan(&self) -> Result<AbortRescan>
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.
In v21 and v22 this creates a legacy wallet. Use create_descriptor_wallet
to create
a descriptor wallet.
Sourcepub fn create_descriptor_wallet(&self, wallet: &str) -> Result<CreateWallet>
pub fn create_descriptor_wallet(&self, wallet: &str) -> Result<CreateWallet>
Creates a wallet with descriptors=true (descriptor wallet).
createwallet “wallet_name” ( disable_private_keys blank “passphrase” avoid_reuse descriptors load_on_startup )
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.
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 encrypt_wallet(&self, passphrase: &str) -> Result<EncryptWallet>
Source§impl Client
impl Client
pub fn get_received_by_label(&self, label: &str) -> Result<GetReceivedByLabel>
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.
Source§impl Client
impl Client
pub fn get_raw_change_address(&self) -> Result<GetRawChangeAddress>
Source§impl Client
impl Client
pub fn get_received_by_address( &self, address: &Address<NetworkChecked>, ) -> Result<GetReceivedByAddress>
Source§impl Client
impl Client
pub fn get_transaction(&self, txid: Txid) -> Result<GetTransaction>
Source§impl Client
impl Client
pub fn get_unconfirmed_balance(&self) -> Result<GetUnconfirmedBalance>
Source§impl Client
impl Client
pub fn get_wallet_info(&self) -> Result<GetWalletInfo>
Source§impl Client
impl Client
pub fn import_descriptors( &self, requests: &[ImportDescriptorsRequest], ) -> Result<ImportDescriptors>
Source§impl Client
impl Client
pub fn import_multi( &self, requests: &[ImportMultiRequest], ) -> Result<ImportMulti>
Source§impl Client
impl Client
pub fn import_privkey(&self, privkey: &PrivateKey) -> Result<()>
Source§impl Client
impl Client
pub fn list_address_groupings(&self) -> Result<ListAddressGroupings>
Source§impl Client
impl Client
pub fn list_labels(&self) -> Result<ListLabels>
Source§impl Client
impl Client
pub fn list_received_by_label(&self) -> Result<ListReceivedByLabel>
Source§impl Client
impl Client
pub fn list_lock_unspent(&self) -> Result<ListLockUnspent>
Source§impl Client
impl Client
pub fn list_received_by_address(&self) -> Result<ListReceivedByAddress>
Source§impl Client
impl Client
pub fn list_since_block(&self) -> Result<ListSinceBlock>
Source§impl Client
impl Client
pub fn list_transactions(&self) -> Result<ListTransactions>
Source§impl Client
impl Client
pub fn list_unspent(&self) -> Result<ListUnspent>
Source§impl Client
impl Client
pub fn list_wallet_dir(&self) -> Result<ListWalletDir>
Source§impl Client
impl Client
pub fn list_wallets(&self) -> Result<ListWallets>
Source§impl Client
impl Client
pub fn load_wallet(&self, filename: &str) -> Result<LoadWallet>
Source§impl Client
impl Client
Sourcepub fn lock_unspent(&self, outputs: &[(Txid, u32)]) -> Result<LockUnspent>
pub fn lock_unspent(&self, outputs: &[(Txid, u32)]) -> Result<LockUnspent>
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>
pub fn unlock_unspent(&self, outputs: &[(Txid, u32)]) -> Result<LockUnspent>
Unlock the given list of transaction outputs. Returns true on success.
This wraps Core RPC: lockunspent true [{"txid":"..","vout":n},...]
.