pub struct AdvancedRpcClient {
pub config: AdvancedRpcConfig,
/* private fields */
}Expand description
Advanced Bitcoin Core RPC client.
Wraps reqwest::Client and handles JSON-RPC v1 authentication,
request serialization, and error handling for advanced operations.
Fields§
§config: AdvancedRpcConfigClient configuration
Implementations§
Source§impl AdvancedRpcClient
impl AdvancedRpcClient
Sourcepub fn new(config: AdvancedRpcConfig) -> Self
pub fn new(config: AdvancedRpcConfig) -> Self
Create a new AdvancedRpcClient from the given configuration.
Sourcepub async fn import_descriptors(
&self,
requests: Vec<DescriptorImportRequest>,
) -> Result<Vec<Value>, BitcoinError>
pub async fn import_descriptors( &self, requests: Vec<DescriptorImportRequest>, ) -> Result<Vec<Value>, BitcoinError>
Import one or more output descriptors into the wallet.
Calls importdescriptors (Bitcoin Core 0.21+).
Sourcepub async fn list_descriptors(
&self,
private: bool,
) -> Result<Vec<DescriptorInfo>, BitcoinError>
pub async fn list_descriptors( &self, private: bool, ) -> Result<Vec<DescriptorInfo>, BitcoinError>
List all descriptors in the wallet.
Calls listdescriptors. Set private to true to include private keys.
Sourcepub async fn get_block_template(&self) -> Result<BlockTemplate, BitcoinError>
pub async fn get_block_template(&self) -> Result<BlockTemplate, BitcoinError>
Retrieve a block template for mining.
Calls getblocktemplate with SegWit rules enabled.
Sourcepub async fn submit_block(
&self,
hex_data: &str,
) -> Result<Option<String>, BitcoinError>
pub async fn submit_block( &self, hex_data: &str, ) -> Result<Option<String>, BitcoinError>
Submit a new block to the network.
Calls submitblock. Returns None on success, or an error string.
Sourcepub async fn prioritise_transaction(
&self,
txid: &str,
fee_delta: i64,
) -> Result<bool, BitcoinError>
pub async fn prioritise_transaction( &self, txid: &str, fee_delta: i64, ) -> Result<bool, BitcoinError>
Assign a higher or lower priority to a mempool transaction.
Calls prioritisetransaction. Returns true on success.
Sourcepub async fn get_mempool_entry(&self, txid: &str) -> Result<Value, BitcoinError>
pub async fn get_mempool_entry(&self, txid: &str) -> Result<Value, BitcoinError>
Retrieve detailed mempool information for a specific transaction.
Calls getmempoolentry.
Sourcepub async fn get_block_height(&self) -> Result<u32, BitcoinError>
pub async fn get_block_height(&self) -> Result<u32, BitcoinError>
Retrieve the current block height.
Calls getblockcount.
Sourcepub async fn get_peer_info(&self) -> Result<Vec<NetworkPeerInfo>, BitcoinError>
pub async fn get_peer_info(&self) -> Result<Vec<NetworkPeerInfo>, BitcoinError>
Get peer information from the node.
Calls getpeerinfo and returns a list of NetworkPeerInfo records.
Sourcepub async fn add_node(
&self,
node: &str,
command: &str,
) -> Result<(), BitcoinError>
pub async fn add_node( &self, node: &str, command: &str, ) -> Result<(), BitcoinError>
Add or remove a node connection.
command must be one of "add", "remove", or "onetry".
Calls addnode.
Sourcepub async fn disconnect_node(&self, node: &str) -> Result<(), BitcoinError>
pub async fn disconnect_node(&self, node: &str) -> Result<(), BitcoinError>
Disconnect from a peer by its network address or numeric node id.
Calls disconnectnode.
Sourcepub async fn send_raw_message(
&self,
peer_id: u64,
message_type: &str,
data: Option<&str>,
) -> Result<SendMessageResult, BitcoinError>
pub async fn send_raw_message( &self, peer_id: u64, message_type: &str, data: Option<&str>, ) -> Result<SendMessageResult, BitcoinError>
Send a raw P2P message to a peer.
peer_id is the node id from getpeerinfo.
message_type is the P2P message type (e.g. "ping", "mempool").
data is an optional hex-encoded payload.
Bitcoin Core does not expose a generic “sendmessage” RPC, so this method
models the call as a ping for ping-type messages and as a no-op
success for others, returning a SendMessageResult indicating outcome.
Sourcepub async fn get_net_totals(&self) -> Result<Value, BitcoinError>
pub async fn get_net_totals(&self) -> Result<Value, BitcoinError>
Get network traffic statistics.
Calls getnettotals and returns the raw JSON value.