main.rs 678 B

1234567891011121314151617181920212223
  1. use std::env::args;
  2. use std::error::Error;
  3. use bitcoincore_rpc::Auth;
  4. use nockchain_bitcoin_sync::{BitcoinRPCConnection, BitcoinWatcher};
  5. #[tokio::main]
  6. async fn main() -> Result<(), Box<dyn Error>> {
  7. let block: u64 = args().collect::<Vec<_>>()[1].parse()?;
  8. let connection = BitcoinRPCConnection::new(
  9. "http://127.0.0.1:8332".to_string(),
  10. /*
  11. Auth::CookieFile(PathBuf::from(
  12. "cookiefile",
  13. )),*/
  14. Auth::None,
  15. block,
  16. );
  17. let watcher = BitcoinWatcher::new(connection).await?;
  18. let block_ref = watcher.watch().await?;
  19. println!("Block {} at height {}", block_ref.hash, block_ref.height);
  20. Ok(())
  21. }