]> Untitled Git - bdk/commitdiff
feat(testenv): add `genesis_hash` method
author志宇 <hello@evanlinjin.me>
Tue, 26 Mar 2024 12:12:51 +0000 (20:12 +0800)
committer志宇 <hello@evanlinjin.me>
Tue, 16 Apr 2024 10:01:51 +0000 (18:01 +0800)
This gets the genesis hash of the env blockchain.

crates/testenv/src/lib.rs

index b0147d0fccaa0fcb7df78ce164e50f9f84e94b04..2edd06eb20d5d633a6fc5d4695f396fe28188dcd 100644 (file)
@@ -250,6 +250,12 @@ impl TestEnv {
         }))
         .expect("must craft tip")
     }
+
+    /// Get the genesis hash of the blockchain.
+    pub fn genesis_hash(&self) -> anyhow::Result<BlockHash> {
+        let hash = self.bitcoind.client.get_block_hash(0)?;
+        Ok(hash)
+    }
 }
 
 #[cfg(test)]