From 190f2269bc4c70f65522b14b5fb486f24d91d646 Mon Sep 17 00:00:00 2001 From: Alekos Filini Date: Thu, 10 Sep 2020 18:08:37 +0200 Subject: [PATCH] [blockchain] Add a trait to create `Blockchain`s from a configuration This is the first set of changes for #42 --- examples/repl.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/examples/repl.rs b/examples/repl.rs index 857d6ab..bcd9a9f 100644 --- a/examples/repl.rs +++ b/examples/repl.rs @@ -37,9 +37,9 @@ use log::{debug, error, info, trace, LevelFilter}; use bitcoin::Network; use bdk::bitcoin; -use bdk::blockchain::ElectrumBlockchain; +use bdk::blockchain::electrum::{ElectrumBlockchain, ElectrumBlockchainConfig}; +use bdk::blockchain::ConfigurableBlockchain; use bdk::cli; -use bdk::electrum_client::Client; use bdk::sled; use bdk::Wallet; @@ -89,17 +89,16 @@ fn main() { .unwrap(); debug!("database opened successfully"); - let client = Client::new( - matches.value_of("server").unwrap(), - matches.value_of("proxy"), - ) - .unwrap(); + let blockchain_config = ElectrumBlockchainConfig { + url: matches.value_of("server").unwrap().to_string(), + socks5: matches.value_of("proxy").map(ToString::to_string), + }; let wallet = Wallet::new( descriptor, change_descriptor, network, tree, - ElectrumBlockchain::from(client), + ElectrumBlockchain::from_config(&blockchain_config).unwrap(), ) .unwrap(); let wallet = Arc::new(wallet); -- 2.49.0