corepc-client library to communicate with Bitcoin nodes via RPC. The library provides type-safe clients for both read and write operations.
Creating a Client
Thecreate_bitcoin_rpc_client() function creates a client that supports both read and write operations:
HTTPS Support
The client supports HTTPS connections automatically:Client Types
Core Lane provides two client interfaces:BitcoinRpcClient
Full read-write client (type alias forcorepc_client::client_sync::v28::Client):
BitcoinRpcReadClient
Read-only trait for queries and verification:Read Operations
TheBitcoinRpcReadClient trait provides methods for querying blockchain data:
Block Height
Block Hash
Block Data
Transaction Data
Blockchain Info
Using with CoreLaneStateForLib
The Bitcoin client is required when creating aCoreLaneStateForLib for transaction execution:
Network Detection
You can detect the Bitcoin network usinggetblockchaininfo:
Error Handling
RPC operations returnanyhow::Result:
Complete Example
Here’s a complete example showing Bitcoin RPC usage:Connection Configuration
The client usescorepc-client which supports:
- Connect timeout: 10 seconds
- Request timeout: 30 seconds
- HTTP and HTTPS: Automatic protocol detection
- Basic authentication: Username and password
Alternative: HttpBitcoinRpcClient
Core Lane also includes an HTTP-only fallback client:create_bitcoin_rpc_client() is recommended as it uses the more robust corepc-client implementation.
See Also
- Transaction Execution - Using Bitcoin client with transaction processing
- Getting Started - Library setup and basic usage