From: Alekos Filini Date: Thu, 10 Sep 2020 16:08:37 +0000 (+0200) Subject: [blockchain] Add a trait to create `Blockchain`s from a configuration X-Git-Tag: v0.1.0~47 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/struct.CommandStringError.html?a=commitdiff_plain;h=190f2269bc4c70f65522b14b5fb486f24d91d646;p=bdk-cli [blockchain] Add a trait to create `Blockchain`s from a configuration This is the first set of changes for #42 --- 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);