pub struct BlockchainInfo {
pub latest_height: usize,
pub latest_blockhash: BlockHash,
+ pub chain: String,
}
impl TryInto<BlockchainInfo> for JsonResponse {
latest_height: self.0["blocks"].as_u64().unwrap() as usize,
latest_blockhash: BlockHash::from_hex(self.0["bestblockhash"].as_str().unwrap())
.unwrap(),
+ chain: self.0["chain"].as_str().unwrap().to_string(),
})
}
}
}
};
+ // Check that the bitcoind we've connected to is running the network we expect
+ let bitcoind_chain = bitcoind_client.get_blockchain_info().await.chain;
+ if bitcoind_chain != match args.network {
+ bitcoin::Network::Bitcoin => "main",
+ bitcoin::Network::Testnet => "test",
+ bitcoin::Network::Regtest => "regtest",
+ bitcoin::Network::Signet => "signet",
+ } {
+ println!("Chain argument ({}) didn't match bitcoind chain ({})", args.network, bitcoind_chain);
+ return;
+ }
+
// ## Setup
// Step 1: Initialize the FeeEstimator