diff --git a/devimint/src/external.rs b/devimint/src/external.rs index 22b59a65a80..052f381e6f8 100644 --- a/devimint/src/external.rs +++ b/devimint/src/external.rs @@ -120,6 +120,15 @@ impl Bitcoind { self.client.clone() } + /// Returns the total number of blocks in the chain. + /// + /// Fedimint's IBitcoindRpc considers block count the total number of + /// blocks, where bitcoind's rpc returns the height. Since the genesis + /// block has height 0, we need to add 1 to get the total block count. + pub fn get_block_count(&self) -> Result { + Ok(self.client().get_block_count()? + 1) + } + pub async fn mine_blocks(&self, block_num: u64) -> Result<()> { info!(target: LOG_DEVIMINT, ?block_num, "Mining bitcoin blocks"); let client = self.client(); diff --git a/devimint/src/federation.rs b/devimint/src/federation.rs index c3585336a0d..a074a8575d1 100644 --- a/devimint/src/federation.rs +++ b/devimint/src/federation.rs @@ -5,7 +5,6 @@ use std::{env, fs}; use anyhow::{anyhow, bail, Context, Result}; use bitcoincore_rpc::bitcoin::Network; -use bitcoincore_rpc::RpcApi; use fedimint_core::admin_client::{ ConfigGenConnectionsRequest, ConfigGenParamsRequest, WsAdminClient, }; @@ -219,10 +218,7 @@ impl Federation { pub async fn await_block_sync(&self) -> Result { let finality_delay = self.get_finality_delay().await?; - // Fedimint's IBitcoindRpc considers block count the total number of blocks, - // where bitcoind's rpc returns the height. Since the genesis block has height - // 0, we need to add 1 to get the total block count. - let block_count = self.bitcoind.client().get_block_count()? + 1; + let block_count = self.bitcoind.get_block_count()?; let expected = block_count.saturating_sub(finality_delay.into()); cmd!(self, "dev", "wait-block-count", expected) .run()