From: Alekos Filini Date: Wed, 15 Jul 2020 16:49:24 +0000 (+0200) Subject: Remove async, upgrade electrum-client X-Git-Tag: 0.1.0-beta.1~24 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/struct.DecoderReader.html?a=commitdiff_plain;h=9fe81ae67968b43988ee757a0764b8b327b64bfe;p=bdk-cli Remove async, upgrade electrum-client --- diff --git a/Cargo.toml b/Cargo.toml index 5137c7f..994ea1b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,12 +11,12 @@ miniscript = { version = "0.12" } serde = { version = "^1.0", features = ["derive"] } serde_json = { version = "^1.0" } base64 = "^0.11" -async-trait = "0.1" # Optional dependencies sled = { version = "0.31.0", optional = true } -electrum-client = { git = "https://github.com/MagicalBitcoin/rust-electrum-client.git", optional = true } +electrum-client = { version = "0.2.0-beta.1", optional = true } reqwest = { version = "0.10", optional = true, features = ["json"] } +tokio = { version = "0.2", optional = true, features = ["rt-core"] } futures = { version = "0.3", optional = true } clap = { version = "2.33", optional = true } @@ -25,12 +25,11 @@ minimal = [] compiler = ["miniscript/compiler"] default = ["key-value-db", "electrum"] electrum = ["electrum-client"] -esplora = ["reqwest", "futures"] +esplora = ["reqwest", "futures", "tokio"] key-value-db = ["sled"] cli-utils = ["clap"] [dev-dependencies] -tokio = { version = "0.2", features = ["macros"] } lazy_static = "1.4" rustyline = "6.0" dirs = "2.0" diff --git a/examples/repl.rs b/examples/repl.rs index 5eaf3f4..1b76321 100644 --- a/examples/repl.rs +++ b/examples/repl.rs @@ -32,8 +32,7 @@ fn prepare_home_dir() -> PathBuf { dir } -#[tokio::main] -async fn main() { +fn main() { env_logger::init(); let app = cli::make_cli_subcommands(); @@ -65,9 +64,11 @@ async fn main() { .unwrap(); debug!("database opened successfully"); - let client = Client::new(matches.value_of("server").unwrap()) - .await - .unwrap(); + let client = Client::new( + matches.value_of("server").unwrap(), + matches.value_of("proxy"), + ) + .unwrap(); let wallet = Wallet::new( descriptor, change_descriptor, @@ -75,7 +76,6 @@ async fn main() { tree, ElectrumBlockchain::from(client), ) - .await .unwrap(); let wallet = Arc::new(wallet); @@ -101,9 +101,8 @@ async fn main() { continue; } - if let Some(s) = cli::handle_matches(&Arc::clone(&wallet), matches.unwrap()) - .await - .unwrap() + if let Some(s) = + cli::handle_matches(&Arc::clone(&wallet), matches.unwrap()).unwrap() { println!("{}", s); } @@ -119,7 +118,7 @@ async fn main() { // rl.save_history("history.txt").unwrap(); } else { - if let Some(s) = cli::handle_matches(&wallet, matches).await.unwrap() { + if let Some(s) = cli::handle_matches(&wallet, matches).unwrap() { println!("{}", s); } } diff --git a/src/cli.rs b/src/cli.rs index a6f3462..5d61ff0 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -242,6 +242,14 @@ pub fn add_global_flags<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { .takes_value(true) .default_value("tn.not.fyi:55001"), ) + .arg( + Arg::with_name("proxy") + .short("p") + .long("proxy") + .value_name("SERVER:PORT") + .help("Sets the SOCKS5 proxy for the Electrum client") + .takes_value(true), + ) .arg( Arg::with_name("descriptor") .short("d") @@ -268,7 +276,7 @@ pub fn add_global_flags<'a, 'b>(app: App<'a, 'b>) -> App<'a, 'b> { .subcommand(SubCommand::with_name("repl").about("Opens an interactive shell")) } -pub async fn handle_matches( +pub fn handle_matches( wallet: &Wallet, matches: ArgMatches<'_>, ) -> Result, Error> @@ -279,7 +287,7 @@ where if let Some(_sub_matches) = matches.subcommand_matches("get_new_address") { Ok(Some(format!("{}", wallet.get_new_address()?))) } else if let Some(_sub_matches) = matches.subcommand_matches("sync") { - wallet.sync(None, None).await?; + wallet.sync(None, None)?; Ok(None) } else if let Some(_sub_matches) = matches.subcommand_matches("list_unspent") { let mut res = String::new(); @@ -374,7 +382,7 @@ where panic!("Missing `psbt` and `tx` option"); }; - let txid = wallet.broadcast(tx).await?; + let txid = wallet.broadcast(tx)?; Ok(Some(format!("TXID: {}", txid))) } else if let Some(sub_matches) = matches.subcommand_matches("extract_psbt") {