use core_lane::{
create_bitcoin_rpc_client,
bitcoin_rpc_client::BitcoinRpcReadClient
};
use anyhow::Result;
#[tokio::main]
async fn main() -> Result<()> {
println!("Connecting to Bitcoin RPC...");
let client = create_bitcoin_rpc_client(
"http://127.0.0.1:18443",
"user",
"password"
)?;
// Get current height
let height = client.get_block_count()?;
println!("Current block height: {}", height);
// Get recent block
if height > 0 {
let hash_hex = client.get_block_hash_hex(height)?;
println!("Latest block hash: {}", hash_hex);
let block = client.get_block_by_hash_hex(&hash_hex)?;
println!("Block merkle root: {}", block.header.merkle_root);
println!("Number of transactions: {}", block.txdata.len());
// Show first transaction (coinbase)
if let Some(tx) = block.txdata.first() {
println!("Coinbase txid: {}", tx.compute_txid());
}
}
// Get blockchain info
let info = client.getblockchaininfo()?;
println!("\nChain: {}", info["chain"].as_str().unwrap_or("unknown"));
println!("Difficulty: {}", info["difficulty"].as_f64().unwrap_or(0.0));
Ok(())
}