]> Untitled Git - bdk-cli/commitdiff
Remove async, upgrade electrum-client
authorAlekos Filini <alekos.filini@gmail.com>
Wed, 15 Jul 2020 16:49:24 +0000 (18:49 +0200)
committerAlekos Filini <alekos.filini@gmail.com>
Fri, 17 Jul 2020 07:44:01 +0000 (09:44 +0200)
Cargo.toml
examples/repl.rs
src/cli.rs

index 5137c7f2d34c6ca34b3dde98bbda55d4759fec4f..994ea1bebdb83ee9330245daf00ae3eea747beb1 100644 (file)
@@ -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"
index 5eaf3f4275931c86b24f4a7b71efb36743bb9454..1b76321cd7afe361d704109813123c23077a3951 100644 (file)
@@ -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);
         }
     }
index a6f34625b14a6dfe8dc3c097df4f2293dd0d19ae..5d61ff0661875b872c05feaa8e608daf84bb09e4 100644 (file)
@@ -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<C, D>(
+pub fn handle_matches<C, D>(
     wallet: &Wallet<C, D>,
     matches: ArgMatches<'_>,
 ) -> Result<Option<String>, 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") {