Skip to content

Commit cd60243

Browse files
committed
Merge #1264: fix(example_electrum): init LocalChain from genesis
5b77942 fix(example_electrum): init LocalChain from genesis (vmammal) Pull request description: <!-- You can erase any parts of this template not applicable to your Pull Request. --> ### Description <!-- Describe the purpose of this PR, what's being adding and/or fixed --> This should fix #1252 ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing ACKs for top commit: evanlinjin: ACK 5b77942 Tree-SHA512: bf049edb2ba22abb949dfd4cb38608589287f3f374f397c82f778b59c21010daa80b63ad85c442c4ee00a2608f89a8d50447b0db85d15caac7fd0b4fd8956e1a
2 parents 264bb85 + 5b77942 commit cd60243

File tree

1 file changed

+7
-2
lines changed
  • example-crates/example_electrum/src

1 file changed

+7
-2
lines changed

example-crates/example_electrum/src/main.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55
};
66

77
use bdk_chain::{
8-
bitcoin::{Address, Network, OutPoint, ScriptBuf, Txid},
8+
bitcoin::{constants::genesis_block, Address, Network, OutPoint, ScriptBuf, Txid},
99
indexed_tx_graph::{self, IndexedTxGraph},
1010
keychain,
1111
local_chain::{self, LocalChain},
@@ -112,7 +112,12 @@ fn main() -> anyhow::Result<()> {
112112
graph
113113
});
114114

115-
let chain = Mutex::new(LocalChain::from_changeset(disk_local_chain)?);
115+
let chain = Mutex::new({
116+
let genesis_hash = genesis_block(args.network).block_hash();
117+
let (mut chain, _) = LocalChain::from_genesis_hash(genesis_hash);
118+
chain.apply_changeset(&disk_local_chain)?;
119+
chain
120+
});
116121

117122
let electrum_cmd = match &args.command {
118123
example_cli::Commands::ChainSpecific(electrum_cmd) => electrum_cmd,

0 commit comments

Comments
 (0)