Get block hash by its height

Create blockchain::GetBlockHash trait
with a method to get block hash given
a block height. Then, implement this
trait for all backends (Electrum, RPC
, Esplora, CBF). Referenced in issue 603.
This commit is contained in:
Vladimir Fomene
2022-06-16 20:42:02 +01:00
parent 1c94108d7e
commit 2af678aa84
9 changed files with 93 additions and 2 deletions

View File

@@ -98,6 +98,13 @@ impl GetTx for ElectrumBlockchain {
}
}
impl GetBlockHash for ElectrumBlockchain {
fn get_block_hash(&self, height: u64) -> Result<BlockHash, Error> {
let block_header = self.client.block_header(height as usize)?;
Ok(block_header.block_hash())
}
}
impl WalletSync for ElectrumBlockchain {
fn wallet_setup<D: BatchDatabase>(
&self,