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 }
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"
dir
}
-#[tokio::main]
-async fn main() {
+fn main() {
env_logger::init();
let app = cli::make_cli_subcommands();
.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,
tree,
ElectrumBlockchain::from(client),
)
- .await
.unwrap();
let wallet = Arc::new(wallet);
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);
}
// 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);
}
}
.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")
.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>
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();
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") {