From e52e81951e229fd79225349951699a034874b65d Mon Sep 17 00:00:00 2001 From: Richard Ulrich Date: Thu, 25 Nov 2021 13:16:00 +0100 Subject: [PATCH 1/2] if no wallet name was provided, use one derived from the descriptor --- CHANGELOG.md | 1 + Cargo.lock | 8 +-- Cargo.toml | 4 +- src/bdk_cli.rs | 52 ++++++++++----- src/lib.rs | 171 ++++++++++++++----------------------------------- 5 files changed, 91 insertions(+), 145 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6924377..7df29d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Replace `wallet bump_fee` command `--send_all` with new `--shrink` option - Add 'reserve' feature to enable proof of reserve +- If no wallet name is provided, derive one from the descriptor instead of using "main" ## [0.3.0] diff --git a/Cargo.lock b/Cargo.lock index 11e2188..cbfd156 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "bdk" -version = "0.14.0" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6ec4da3dbaa41bb6d6cffe40b113ea8651566da7f96beebe9c0e87fc92b9094" +checksum = "90456af1a5ceb48721ce092d97bd37d2d932c2877a352f52c934d8a564f62e49" dependencies = [ "async-trait", "bdk-macros", @@ -139,9 +139,9 @@ dependencies = [ [[package]] name = "bdk-reserves" -version = "0.14.3" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af45ab67ba3a9e2bf44c0567a89b60cdcf3bcc21ae52938d98c8d2eaa1078a08" +checksum = "6be281faf67beffdfbdb2b049dba1f97d58c7f46ff9d9586811c813d7abf9485" dependencies = [ "base64 0.11.0", "bdk", diff --git a/Cargo.toml b/Cargo.toml index 07e5b7c..9319bc3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ readme = "README.md" license = "MIT" [dependencies] -bdk = { version = "0.14.0", default-features = false, features = ["all-keys"]} +bdk = { version = "0.15", default-features = false, features = ["all-keys"]} bdk-macros = "0.6" structopt = "^0.3" serde_json = { version = "^1.0" } @@ -26,7 +26,7 @@ dirs-next = { version = "2.0", optional = true } env_logger = { version = "0.7", optional = true } clap = { version = "2.33", optional = true } regex = { version = "1", optional = true } -bdk-reserves = { version = "0.14.2", optional = true} +bdk-reserves = { version = "0.15", optional = true} [features] default = ["cli", "repl"] diff --git a/src/bdk_cli.rs b/src/bdk_cli.rs index 4902b03..baa12cf 100644 --- a/src/bdk_cli.rs +++ b/src/bdk_cli.rs @@ -22,12 +22,11 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. +use bitcoin::secp256k1::Secp256k1; +use bitcoin::Network; use std::fs; use std::path::PathBuf; -#[cfg(feature = "rpc")] -use bitcoin::secp256k1::Secp256k1; -use bitcoin::Network; use clap::AppSettings; use log::{debug, error, info, warn}; @@ -54,11 +53,12 @@ use bdk::blockchain::esplora::EsploraBlockchainConfig; use bdk::blockchain::{AnyBlockchain, AnyBlockchainConfig, ConfigurableBlockchain}; #[cfg(feature = "rpc")] -use bdk::blockchain::rpc::{wallet_name_from_descriptor, Auth, RpcConfig}; +use bdk::blockchain::rpc::{Auth, RpcConfig}; use bdk::database::BatchDatabase; use bdk::sled; use bdk::sled::Tree; +use bdk::wallet::wallet_name_from_descriptor; use bdk::Wallet; use bdk::{bitcoin, Error}; use bdk_cli::WalletSubCommand; @@ -122,9 +122,13 @@ fn prepare_home_dir() -> Result { fn open_database(wallet_opts: &WalletOpts) -> Result { let mut database_path = prepare_home_dir()?; - database_path.push(wallet_opts.wallet.clone()); + let wallet_name = wallet_opts + .wallet + .as_deref() + .expect("We should always have a wallet name at this point"); + database_path.push(wallet_name); let database = sled::open(database_path)?; - let tree = database.open_tree(&wallet_opts.wallet)?; + let tree = database.open_tree(&wallet_name)?; debug!("database opened successfully"); Ok(tree) } @@ -152,18 +156,10 @@ where stop_gap: wallet_opts.electrum_opts.stop_gap, }); - #[cfg(feature = "esplora-ureq")] - let config = AnyBlockchainConfig::Esplora(EsploraBlockchainConfig { - base_url: wallet_opts.esplora_opts.server.clone(), - timeout_read: wallet_opts.esplora_opts.read_timeout, - timeout_write: wallet_opts.esplora_opts.write_timeout, - stop_gap: wallet_opts.esplora_opts.stop_gap, - proxy: wallet_opts.proxy_opts.proxy.clone(), - }); - - #[cfg(feature = "esplora-reqwest")] + #[cfg(feature = "esplora")] let config = AnyBlockchainConfig::Esplora(EsploraBlockchainConfig { base_url: wallet_opts.esplora_opts.server.clone(), + timeout: Some(wallet_opts.esplora_opts.timeout), concurrency: Some(wallet_opts.esplora_opts.conc), stop_gap: wallet_opts.esplora_opts.stop_gap, proxy: wallet_opts.proxy_opts.proxy.clone(), @@ -263,13 +259,33 @@ fn main() { Ok(result) => println!("{}", result), Err(e) => { match e { - Error::ChecksumMismatch => error!("Descriptor checksum mismatch. Are you using a different descriptor for an already defined wallet name? (if you are not specifying the wallet name it defaults to 'main')"), + Error::ChecksumMismatch => error!("Descriptor checksum mismatch. Are you using a different descriptor for an already defined wallet name? (if you are not specifying the wallet name it is automatically named based on the descriptor)"), e => error!("{}", e.to_string()), } }, } } +fn maybe_descriptor_wallet_name( + wallet_opts: WalletOpts, + network: Network, +) -> Result { + if wallet_opts.wallet.is_some() { + return Ok(wallet_opts); + } + // Use deterministic wallet name derived from descriptor + let wallet_name = wallet_name_from_descriptor( + &wallet_opts.descriptor[..], + wallet_opts.change_descriptor.as_deref(), + network, + &Secp256k1::new(), + )?; + let mut wallet_opts = wallet_opts; + wallet_opts.wallet = Some(wallet_name); + + Ok(wallet_opts) +} + fn handle_command(cli_opts: CliOpts, network: Network) -> Result { let result = match cli_opts.subcommand { #[cfg(any( @@ -282,6 +298,7 @@ fn handle_command(cli_opts: CliOpts, network: Network) -> Result wallet_opts, subcommand: WalletSubCommand::OnlineWalletSubCommand(online_subcommand), } => { + let wallet_opts = maybe_descriptor_wallet_name(wallet_opts, network)?; let database = open_database(&wallet_opts)?; let wallet = new_online_wallet(network, &wallet_opts, database)?; let result = bdk_cli::handle_online_wallet_subcommand(&wallet, online_subcommand)?; @@ -291,6 +308,7 @@ fn handle_command(cli_opts: CliOpts, network: Network) -> Result wallet_opts, subcommand: WalletSubCommand::OfflineWalletSubCommand(offline_subcommand), } => { + let wallet_opts = maybe_descriptor_wallet_name(wallet_opts, network)?; let database = open_database(&wallet_opts)?; let wallet = new_offline_wallet(network, &wallet_opts, database)?; let result = bdk_cli::handle_offline_wallet_subcommand( diff --git a/src/lib.rs b/src/lib.rs index 71c8d60..4950dc2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -209,7 +209,7 @@ use bdk_reserves::reserves::ProofOfReserves; /// network: Network::Testnet, /// subcommand: CliSubCommand::Wallet { /// wallet_opts: WalletOpts { -/// wallet: "main".to_string(), +/// wallet: None, /// verbose: false, /// descriptor: "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/44'/1'/0'/0/*)".to_string(), /// change_descriptor: None, @@ -219,18 +219,12 @@ use bdk_reserves::reserves::ProofOfReserves; /// server: "ssl://electrum.blockstream.info:60002".to_string(), /// stop_gap: 10 /// }, -/// #[cfg(feature = "esplora-ureq")] +/// #[cfg(feature = "esplora")] /// esplora_opts: EsploraOpts { /// server: "https://blockstream.info/testnet/api/".to_string(), -/// read_timeout: 5, -/// write_timeout: 5, -/// stop_gap: 10 -/// }, -/// #[cfg(feature = "esplora-reqwest")] -/// esplora_opts: EsploraOpts { -/// server: "https://blockstream.info/testnet/api/".to_string(), -/// conc: 4, -/// stop_gap: 10 +/// timeout: 5, +/// stop_gap: 10, +/// conc: 4 /// }, /// #[cfg(feature = "rpc")] /// rpc_opts: RpcOpts{ @@ -395,7 +389,7 @@ pub enum WalletSubCommand { /// let wallet_opts = WalletOpts::from_iter(&cli_args); /// /// let expected_wallet_opts = WalletOpts { -/// wallet: "main".to_string(), +/// wallet: None, /// verbose: false, /// descriptor: "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/44'/1'/0'/0/*)".to_string(), /// change_descriptor: None, @@ -405,18 +399,12 @@ pub enum WalletSubCommand { /// server: "ssl://electrum.blockstream.info:60002".to_string(), /// stop_gap: 10 /// }, -/// #[cfg(feature = "esplora-ureq")] +/// #[cfg(feature = "esplora")] /// esplora_opts: EsploraOpts { /// server: "https://blockstream.info/testnet/api/".to_string(), -/// read_timeout: 5, -/// write_timeout: 5, -/// stop_gap: 10 -/// }, -/// #[cfg(feature = "esplora-reqwest")] -/// esplora_opts: EsploraOpts { -/// server: "https://blockstream.info/testnet/api/".to_string(), -/// conc: 4, -/// stop_gap: 10 +/// timeout: 5, +/// stop_gap: 10, +/// conc: 4 /// }, /// #[cfg(feature = "compact_filters")] /// compactfilter_opts: CompactFilterOpts{ @@ -444,13 +432,8 @@ pub enum WalletSubCommand { #[derive(Debug, StructOpt, Clone, PartialEq)] pub struct WalletOpts { /// Selects the wallet to use - #[structopt( - name = "WALLET_NAME", - short = "w", - long = "wallet", - default_value = "main" - )] - pub wallet: String, + #[structopt(name = "WALLET_NAME", short = "w", long = "wallet")] + pub wallet: Option, /// Adds verbosity, returns PSBT in JSON format alongside serialized, displays expanded objects #[structopt(name = "VERBOSE", short = "v", long = "verbose")] pub verbose: bool, @@ -588,7 +571,7 @@ pub struct ElectrumOpts { /// Esplora options /// /// Esplora blockchain client information used by [`OnlineWalletSubCommand`]s. -#[cfg(feature = "esplora-ureq")] +#[cfg(feature = "esplora")] #[derive(Debug, StructOpt, Clone, PartialEq)] pub struct EsploraOpts { /// Use the esplora server if given as parameter @@ -600,13 +583,9 @@ pub struct EsploraOpts { )] pub server: String, - /// Socket read timeout - #[structopt(name = "READ_TIMEOUT", long = "read_timeout", default_value = "5")] - pub read_timeout: u64, - - /// Socket write timeout - #[structopt(name = "WRITE_TIMEOUT", long = "write_timeout", default_value = "5")] - pub write_timeout: u64, + /// Socket timeout + #[structopt(name = "TIMEOUT", long = "timeout", default_value = "5")] + pub timeout: u64, /// Stop searching addresses for transactions after finding an unused gap of this length. #[structopt( @@ -616,32 +595,10 @@ pub struct EsploraOpts { default_value = "10" )] pub stop_gap: usize, -} - -#[cfg(feature = "esplora-reqwest")] -#[derive(Debug, StructOpt, Clone, PartialEq)] -pub struct EsploraOpts { - /// Use the esplora server if given as parameter - #[structopt( - name = "ESPLORA_URL", - short = "s", - long = "server", - default_value = "https://blockstream.info/testnet/api/" - )] - pub server: String, /// Number of parallel requests sent to the esplora service (default: 4) #[structopt(name = "CONCURRENCY", long = "conc", default_value = "4")] pub conc: u8, - - /// Stop searching addresses for transactions after finding an unused gap of this length. - #[structopt( - name = "STOP_GAP", - long = "stop_gap", - short = "g", - default_value = "10" - )] - pub stop_gap: usize, } // This is a workaround for `structopt` issue #333, #391, #418; see https://github.com/TeXitoi/structopt/issues/333#issuecomment-712265332 @@ -1467,7 +1424,7 @@ mod test { network: Network::Bitcoin, subcommand: CliSubCommand::Wallet { wallet_opts: WalletOpts { - wallet: "main".to_string(), + wallet: None, verbose: false, descriptor: "wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)".to_string(), change_descriptor: Some("wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)".to_string()), @@ -1477,18 +1434,12 @@ mod test { server: "ssl://electrum.blockstream.info:60002".to_string(), stop_gap: 10, }, - #[cfg(feature = "esplora-ureq")] + #[cfg(feature = "esplora")] esplora_opts: EsploraOpts { server: "https://blockstream.info/testnet/api/".to_string(), - read_timeout: 5, - write_timeout: 5, + timeout: 5, stop_gap: 10, - }, - #[cfg(feature = "esplora-reqwest")] - esplora_opts: EsploraOpts { - server: "https://blockstream.info/testnet/api/".to_string(), conc: 4, - stop_gap: 10, }, #[cfg(feature = "compact_filters")] compactfilter_opts: CompactFilterOpts{ @@ -1533,7 +1484,7 @@ mod test { network: Network::Testnet, subcommand: CliSubCommand::Wallet { wallet_opts: WalletOpts { - wallet: "main".to_string(), + wallet: None, verbose: false, descriptor: "wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)".to_string(), change_descriptor: Some("wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)".to_string()), @@ -1562,8 +1513,7 @@ mod test { "--descriptor", "wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)", "--change_descriptor", "wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)", "--server", "https://blockstream.info/api/", - "--read_timeout", "10", - "--write_timeout", "10", + "--timeout", "10", "--stop_gap", "20", "get_new_address"]; @@ -1573,15 +1523,15 @@ mod test { network: Network::Bitcoin, subcommand: CliSubCommand::Wallet { wallet_opts: WalletOpts { - wallet: "main".to_string(), + wallet: None, verbose: false, descriptor: "wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)".to_string(), change_descriptor: Some("wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)".to_string()), esplora_opts: EsploraOpts { server: "https://blockstream.info/api/".to_string(), - read_timeout: 10, - write_timeout: 10, - stop_gap: 20 + timeout: 10, + stop_gap: 20, + conc: 4, }, proxy_opts: ProxyOpts{ proxy: None, @@ -1613,14 +1563,15 @@ mod test { network: Network::Bitcoin, subcommand: CliSubCommand::Wallet { wallet_opts: WalletOpts { - wallet: "main".to_string(), + wallet: None, verbose: false, descriptor: "wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)".to_string(), change_descriptor: Some("wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)".to_string()), esplora_opts: EsploraOpts { server: "https://blockstream.info/api/".to_string(), conc: 10, - stop_gap: 20 + stop_gap: 20, + timeout: 5, }, proxy_opts: ProxyOpts{ proxy: None, @@ -1652,7 +1603,7 @@ mod test { network: Network::Bitcoin, subcommand: CliSubCommand::Wallet { wallet_opts: WalletOpts { - wallet: "main".to_string(), + wallet: None, verbose: false, descriptor: "wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)".to_string(), change_descriptor: Some("wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)".to_string()), @@ -1688,7 +1639,7 @@ mod test { network: Network::Bitcoin, subcommand: CliSubCommand::Wallet { wallet_opts: WalletOpts { - wallet: "main".to_string(), + wallet: None, verbose: false, descriptor: "wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)".to_string(), change_descriptor: Some("wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)".to_string()), @@ -1728,7 +1679,7 @@ mod test { network: Network::Testnet, subcommand: CliSubCommand::Wallet { wallet_opts: WalletOpts { - wallet: "main".to_string(), + wallet: None, verbose: false, descriptor: "wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)".to_string(), change_descriptor: None, @@ -1738,18 +1689,12 @@ mod test { server: "ssl://electrum.blockstream.info:60002".to_string(), stop_gap: 10, }, - #[cfg(feature = "esplora-ureq")] + #[cfg(feature = "esplora")] esplora_opts: EsploraOpts { server: "https://blockstream.info/testnet/api/".to_string(), - read_timeout: 5, - write_timeout: 5, + timeout: 5, stop_gap: 10, - }, - #[cfg(feature = "esplora-reqwest")] - esplora_opts: EsploraOpts { - server: "https://blockstream.info/testnet/api/".to_string(), conc: 4, - stop_gap: 10, }, #[cfg(feature = "compact_filters")] compactfilter_opts: CompactFilterOpts{ @@ -1809,7 +1754,7 @@ mod test { network: Network::Testnet, subcommand: CliSubCommand::Wallet { wallet_opts: WalletOpts { - wallet: "main".to_string(), + wallet: None, verbose: false, descriptor: "wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)".to_string(), change_descriptor: Some("wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)".to_string()), @@ -1819,18 +1764,12 @@ mod test { server: "ssl://electrum.blockstream.info:60002".to_string(), stop_gap: 10, }, - #[cfg(feature = "esplora-ureq")] + #[cfg(feature = "esplora")] esplora_opts: EsploraOpts { server: "https://blockstream.info/testnet/api/".to_string(), - read_timeout: 5, - write_timeout: 5, + timeout: 5, stop_gap: 10, - }, - #[cfg(feature = "esplora-reqwest")] - esplora_opts: EsploraOpts { - server: "https://blockstream.info/testnet/api/".to_string(), conc: 4, - stop_gap: 10, }, #[cfg(feature = "compact_filters")] compactfilter_opts: CompactFilterOpts{ @@ -1883,7 +1822,7 @@ mod test { network: Network::Testnet, subcommand: CliSubCommand::Wallet { wallet_opts: WalletOpts { - wallet: "main".to_string(), + wallet: None, verbose: false, descriptor: "wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)".to_string(), change_descriptor: Some("wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)".to_string()), @@ -1893,18 +1832,12 @@ mod test { server: "ssl://electrum.blockstream.info:60002".to_string(), stop_gap: 10, }, - #[cfg(feature = "esplora-ureq")] + #[cfg(feature = "esplora")] esplora_opts: EsploraOpts { server: "https://blockstream.info/testnet/api/".to_string(), - read_timeout: 5, - write_timeout: 5, + timeout: 5, stop_gap: 10, - }, - #[cfg(feature = "esplora-reqwest")] - esplora_opts: EsploraOpts { - server: "https://blockstream.info/testnet/api/".to_string(), conc: 4, - stop_gap: 10, }, #[cfg(feature = "compact_filters")] compactfilter_opts: CompactFilterOpts{ @@ -1958,7 +1891,7 @@ mod test { network: Network::Testnet, subcommand: CliSubCommand::Wallet { wallet_opts: WalletOpts { - wallet: "main".to_string(), + wallet: None, verbose: false, descriptor: "wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)".to_string(), change_descriptor: None, @@ -1968,18 +1901,12 @@ mod test { server: "ssl://electrum.blockstream.info:60002".to_string(), stop_gap: 10, }, - #[cfg(feature = "esplora-ureq")] + #[cfg(feature = "esplora")] esplora_opts: EsploraOpts { server: "https://blockstream.info/testnet/api/".to_string(), - read_timeout: 5, - write_timeout: 5, + timeout: 5, stop_gap: 10, - }, - #[cfg(feature = "esplora-reqwest")] - esplora_opts: EsploraOpts { - server: "https://blockstream.info/testnet/api/".to_string(), conc: 4, - stop_gap: 10, }, #[cfg(feature = "compact_filters")] compactfilter_opts: CompactFilterOpts{ @@ -2140,7 +2067,7 @@ mod test { network: Network::Bitcoin, subcommand: CliSubCommand::Wallet { wallet_opts: WalletOpts { - wallet: "main".to_string(), + wallet: None, verbose: false, descriptor: "wpkh(cVpPVruEDdmutPzisEsYvtST1usBR3ntr8pXSyt6D2YYqXRyPcFW)" .to_string(), @@ -2190,16 +2117,16 @@ mod test { network: Network::Bitcoin, subcommand: CliSubCommand::Wallet { wallet_opts: WalletOpts { - wallet: "main".to_string(), + wallet: None, verbose: false, descriptor: "wpkh(cVpPVruEDdmutPzisEsYvtST1usBR3ntr8pXSyt6D2YYqXRyPcFW)" .to_string(), change_descriptor: None, esplora_opts: EsploraOpts { server: "https://blockstream.info/testnet/api/".to_string(), - read_timeout: 5, - write_timeout: 5, + timeout: 5, stop_gap: 10, + conc: 4, }, proxy_opts: ProxyOpts { proxy: None, @@ -2245,16 +2172,16 @@ mod test { network: Network::Bitcoin, subcommand: CliSubCommand::Wallet { wallet_opts: WalletOpts { - wallet: "main".to_string(), + wallet: None, verbose: false, descriptor: "wpkh(cVpPVruEDdmutPzisEsYvtST1usBR3ntr8pXSyt6D2YYqXRyPcFW)" .to_string(), change_descriptor: None, esplora_opts: EsploraOpts { server: "https://blockstream.info/testnet/api/".to_string(), - read_timeout: 5, - write_timeout: 5, + timeout: 5, stop_gap: 10, + conc: 4, }, proxy_opts: ProxyOpts { proxy: None, From 9b278bd91c17d4f01740cfd15e67c96fd2b40911 Mon Sep 17 00:00:00 2001 From: Richard Ulrich Date: Tue, 25 Jan 2022 10:16:06 +0100 Subject: [PATCH 2/2] Bump bdk and bdk-reserves version to 0.16 --- Cargo.lock | 230 ++--------------------------------------------------- Cargo.toml | 4 +- 2 files changed, 9 insertions(+), 225 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cbfd156..9642e5d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,9 +80,9 @@ dependencies = [ [[package]] name = "bdk" -version = "0.15.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90456af1a5ceb48721ce092d97bd37d2d932c2877a352f52c934d8a564f62e49" +checksum = "636aafcdd74940530a9ea644e3def456b493ec42fdd0bd2bb1ae3338b2032849" dependencies = [ "async-trait", "bdk-macros", @@ -96,7 +96,7 @@ dependencies = [ "lazy_static", "log", "miniscript", - "rand 0.7.3", + "rand", "reqwest", "rocksdb", "serde", @@ -139,9 +139,9 @@ dependencies = [ [[package]] name = "bdk-reserves" -version = "0.15.0" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6be281faf67beffdfbdb2b049dba1f97d58c7f46ff9d9586811c813d7abf9485" +checksum = "85397162a769b6162033c4ed8edc6285d347006eac5299dd186dee7bd77e8c88" dependencies = [ "base64 0.11.0", "bdk", @@ -339,22 +339,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "core-foundation" -version = "0.9.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" - [[package]] name = "crc32fast" version = "1.3.0" @@ -485,21 +469,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.0.1" @@ -758,19 +727,6 @@ dependencies = [ "want", ] -[[package]] -name = "hyper-tls" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" -dependencies = [ - "bytes", - "hyper", - "native-tls", - "tokio", - "tokio-native-tls", -] - [[package]] name = "idna" version = "0.2.1" @@ -972,24 +928,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "native-tls" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48ba9f7719b5a0f42f338907614285fb5fd70e53858141f69898a1fb7203b24d" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "nibble_vec" version = "0.1.0" @@ -1038,39 +976,6 @@ version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" -[[package]] -name = "openssl" -version = "0.10.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95" -dependencies = [ - "bitflags", - "cfg-if", - "foreign-types", - "libc", - "once_cell", - "openssl-sys", -] - -[[package]] -name = "openssl-probe" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" - -[[package]] -name = "openssl-sys" -version = "0.9.71" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7df13d165e607909b363a4757a6f133f8a818a74e9d3a98d09c6128e15fa4c73" -dependencies = [ - "autocfg", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "parking_lot" version = "0.11.2" @@ -1120,12 +1025,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "pkg-config" -version = "0.3.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1a3ea4f0dd7f1f3e512cf97bf100819aa547f36a6eccac8dbaae839eb92363e" - [[package]] name = "ppv-lite86" version = "0.2.15" @@ -1198,21 +1097,9 @@ checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ "getrandom 0.1.16", "libc", - "rand_chacha 0.2.2", + "rand_chacha", "rand_core 0.5.1", - "rand_hc 0.2.0", -] - -[[package]] -name = "rand" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" -dependencies = [ - "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.3", - "rand_hc 0.3.1", + "rand_hc", ] [[package]] @@ -1225,16 +1112,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core 0.6.3", -] - [[package]] name = "rand_core" version = "0.4.2" @@ -1250,15 +1127,6 @@ dependencies = [ "getrandom 0.1.16", ] -[[package]] -name = "rand_core" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" -dependencies = [ - "getrandom 0.2.3", -] - [[package]] name = "rand_hc" version = "0.2.0" @@ -1268,15 +1136,6 @@ dependencies = [ "rand_core 0.5.1", ] -[[package]] -name = "rand_hc" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" -dependencies = [ - "rand_core 0.6.3", -] - [[package]] name = "redox_syscall" version = "0.2.10" @@ -1313,15 +1172,6 @@ version = "0.6.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" -[[package]] -name = "remove_dir_all" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" -dependencies = [ - "winapi 0.3.9", -] - [[package]] name = "reqwest" version = "0.11.7" @@ -1336,20 +1186,17 @@ dependencies = [ "http", "http-body", "hyper", - "hyper-tls", "ipnet", "js-sys", "lazy_static", "log", "mime", - "native-tls", "percent-encoding", "pin-project-lite", "serde", "serde_json", "serde_urlencoded", "tokio", - "tokio-native-tls", "tokio-socks", "url", "wasm-bindgen", @@ -1445,16 +1292,6 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568" -[[package]] -name = "schannel" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" -dependencies = [ - "lazy_static", - "winapi 0.3.9", -] - [[package]] name = "scopeguard" version = "1.1.0" @@ -1490,29 +1327,6 @@ dependencies = [ "cc", ] -[[package]] -name = "security-framework" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23a2ac85147a3a11d77ecf1bc7166ec0b92febfa4461c37944e180f319ece467" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9dd14d83160b528b7bfd66439110573efcfbe281b17fc2ca9f39f550d619c7e" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "serde" version = "1.0.131" @@ -1674,20 +1488,6 @@ dependencies = [ "unicode-xid", ] -[[package]] -name = "tempfile" -version = "3.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" -dependencies = [ - "cfg-if", - "libc", - "rand 0.8.4", - "redox_syscall", - "remove_dir_all", - "winapi 0.3.9", -] - [[package]] name = "termcolor" version = "1.1.2" @@ -1741,16 +1541,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "tokio-native-tls" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" -dependencies = [ - "native-tls", - "tokio", -] - [[package]] name = "tokio-socks" version = "0.5.1" @@ -1885,12 +1675,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "936e4b492acfd135421d8dca4b1aa80a7bfc26e702ef3af710e0752684df5372" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "vec_map" version = "0.8.2" diff --git a/Cargo.toml b/Cargo.toml index 9319bc3..a71c542 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ readme = "README.md" license = "MIT" [dependencies] -bdk = { version = "0.15", default-features = false, features = ["all-keys"]} +bdk = { version = "0.16", default-features = false, features = ["all-keys"]} bdk-macros = "0.6" structopt = "^0.3" serde_json = { version = "^1.0" } @@ -26,7 +26,7 @@ dirs-next = { version = "2.0", optional = true } env_logger = { version = "0.7", optional = true } clap = { version = "2.33", optional = true } regex = { version = "1", optional = true } -bdk-reserves = { version = "0.15", optional = true} +bdk-reserves = { version = "0.16", optional = true} [features] default = ["cli", "repl"]