#[cfg(feature = "compact_filters")]
#[structopt(flatten)]
pub compactfilter_opts: CompactFilterOpts,
+
+ #[cfg(any(feature = "compact_filters", feature = "electrum"))]
+ #[structopt(flatten)]
+ pub proxy_opts: ProxyOpts,
}
-/// Compact Filter options
+/// Proxy Server options
///
-/// Compact filter peer information used by [`OnlineWalletSubCommand`]s.
-#[cfg(feature = "compact_filters")]
+/// Only activated for `compact_filters` or `electrum`
+#[cfg(any(feature = "compact_filters", feature = "electrum"))]
#[derive(Debug, StructOpt, Clone, PartialEq)]
-pub struct CompactFilterOpts {
- /// Sets the SOCKS5 proxy for the Electrum client
- #[structopt(name = "CPROXY_SERVER:PORT", long = "cmpct_proxy")]
+pub struct ProxyOpts {
+ /// Sets the SOCKS5 proxy for Blockchain backend
+ #[structopt(name = "PROXY_ADDRS:PORT", long = "proxy", short = "p")]
pub proxy: Option<String>,
- #[structopt(name = "PROXY_SERVER:USER", short = "u", long = "user")]
- pub user: Option<String>,
+ /// Sets the SOCKS5 proxy credential
+ #[structopt(name="PRXOY_USER:PASSWD", long="proxy_auth", short="a", parse(try_from_str = parse_proxy_auth))]
+ pub proxy_auth: Option<(String, String)>,
- #[structopt(name = "PROXY_SERVER:PASSWD", long = "passwd")]
- pub passwd: Option<String>,
+ /// Sets the SOCKS5 proxy retries for the Electrum client
+ #[structopt(
+ name = "PROXY_RETRIES",
+ short = "r",
+ long = "retries",
+ default_value = "5"
+ )]
+ pub retries: u8,
+}
- /// Sets the light client network address
- #[structopt(name = "ADDRESS:PORT", short = "n", long = "node")]
- pub address: String,
+/// Compact Filter options
+///
+/// Compact filter peer information used by [`OnlineWalletSubCommand`]s.
+#[cfg(feature = "compact_filters")]
+#[derive(Debug, StructOpt, Clone, PartialEq)]
+pub struct CompactFilterOpts {
+ /// Sets the full node network address
+ #[structopt(
+ name = "ADDRESS:PORT",
+ short = "n",
+ long = "node",
+ default_value = "127.0.0.1:18444"
+ )]
+ pub address: Vec<String>,
- /// Sets the number of parallel node connection
- #[structopt(name = "CONNECTIONS", long = "conn_count", default_value = "1")]
+ /// Sets the number of parallel node connections
+ #[structopt(name = "CONNECTIONS", long = "conn_count", default_value = "4")]
pub conn_count: usize,
/// Optionally skip initial `skip_blocks` blocks
#[cfg(feature = "electrum")]
#[derive(Debug, StructOpt, Clone, PartialEq)]
pub struct ElectrumOpts {
- /// Sets the SOCKS5 proxy for the Electrum client
- #[structopt(name = "PROXY_SERVER:PORT", short = "p", long = "proxy")]
- pub proxy: Option<String>,
- /// Sets the SOCKS5 proxy retries for the Electrum client
- #[structopt(
- name = "PROXY_RETRIES",
- short = "r",
- long = "retries",
- default_value = "5"
- )]
- pub retries: u8,
/// Sets the SOCKS5 proxy timeout for the Electrum client
#[structopt(name = "PROXY_TIMEOUT", short = "t", long = "timeout")]
pub timeout: Option<u8>,
Ok((addr.unwrap().script_pubkey(), val.unwrap()))
}
+fn parse_proxy_auth(s: &str) -> Result<(String, String), String> {
+ let parts: Vec<_> = s.split(':').collect();
+ if parts.len() != 2 {
+ return Err("Invalid format".to_string());
+ }
+
+ let user = parts[0].to_string();
+ let passwd = parts[1].to_string();
+
+ Ok((user, passwd))
+}
+
fn parse_outpoint(s: &str) -> Result<OutPoint, String> {
OutPoint::from_str(s).map_err(|e| format!("{:?}", e))
}
use crate::EsploraOpts;
use crate::OfflineWalletSubCommand::{CreateTx, GetNewAddress};
use crate::OnlineWalletSubCommand::{Broadcast, Sync};
+ #[cfg(any(feature = "cpmpact_filters", feature = "electrum"))]
+ use crate::ProxyOpts;
use crate::{handle_key_subcommand, CliSubCommand, KeySubCommand, WalletSubCommand};
use bdk::bitcoin::{Address, Network, OutPoint};
change_descriptor: Some("wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)".to_string()),
#[cfg(feature = "electrum")]
electrum_opts: ElectrumOpts {
- proxy: None,
- retries: 5,
timeout: None,
electrum: "ssl://electrum.blockstream.info:60002".to_string()
},
},
#[cfg(feature = "compact_filters")]
compactfilter_opts: CompactFilterOpts{
- proxy: Some("127.0.0.1:9005".to_string()),
- user: Some("random_user".to_string()),
- passwd: Some("random_passwd".to_string()),
- address: "127.0.0.1:18444".to_string(),
+ address: vec!["127.0.0.1:18444".to_string()],
conn_count: 4,
- skip_blocks: 5,
+ skip_blocks: 0,
},
+ #[cfg(any(feature="compact_filetrs", feature="electrum"))]
+ proxy_opts: ProxyOpts{
+ proxy: None,
+ proxy_auth: None,
+ retries: 5,
+ }
},
subcommand: WalletSubCommand::OfflineWalletSubCommand(GetNewAddress),
},
change_descriptor: Some("wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)".to_string()),
#[cfg(feature = "electrum")]
electrum_opts: ElectrumOpts {
- proxy: Some("127.0.0.1:9150".to_string()),
- retries: 3,
timeout: Some(10),
electrum: "ssl://electrum.blockstream.info:50002".to_string(),
},
},
#[cfg(feature = "compact_filters")]
compactfilter_opts: CompactFilterOpts{
- proxy: Some("127.0.0.1:9005".to_string()),
- user: Some("random_user".to_string()),
- passwd: Some("random_passwd".to_string()),
- address: "127.0.0.1:18444".to_string(),
+ address: vec!["127.0.0.1:18444".to_string()],
conn_count: 4,
- skip_blocks: 5,
+ skip_blocks: 0,
},
+ #[cfg(any(feature="compact_filetrs", feature="electrum"))]
+ proxy_opts: ProxyOpts{
+ proxy: Some("127.0.0.1:9150".to_string()),
+ proxy_auth: None,
+ retries: 3,
+ }
},
subcommand: WalletSubCommand::OfflineWalletSubCommand(GetNewAddress),
},
change_descriptor: Some("wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)".to_string()),
#[cfg(feature = "electrum")]
electrum_opts: ElectrumOpts {
- proxy: None,
- retries: 5,
timeout: None,
electrum: "ssl://electrum.blockstream.info:60002".to_string(),
},
},
#[cfg(feature = "compact_filters")]
compactfilter_opts: CompactFilterOpts{
- address: "127.0.0.1:18444".to_string(),
- skip_blocks: None
+ address: vec!["127.0.0.1:18444".to_string()],
+ skip_blocks: 0,
+ conn_count: 4,
},
+ #[cfg(any(feature="compact_filetrs", feature="electrum"))]
+ proxy_opts: ProxyOpts{
+ proxy: None,
+ proxy_auth: None,
+ retries: 5,
+ }
},
subcommand: WalletSubCommand::OfflineWalletSubCommand(GetNewAddress),
},
let cli_args = vec!["bdk-cli", "--network", "bitcoin", "wallet",
"--descriptor", "wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/0/*)",
"--change_descriptor", "wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)",
- "--cmpct_proxy", "127.0.0.1:9005",
- "-u", "random_user",
- "--passwd", "random_passwd",
- "--node", "127.0.0.1:18444",
+ "--proxy", "127.0.0.1:9005",
+ "--proxy_auth", "random_user:random_passwd",
+ "--node", "127.0.0.1:18444", "127.2.3.1:19695",
"--conn_count", "4",
"--skip_blocks", "5",
"get_new_address"];
change_descriptor: Some("wpkh(xpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)".to_string()),
#[cfg(feature = "electrum")]
electrum_opts: ElectrumOpts {
- proxy: None,
- retries: 5,
timeout: None,
electrum: "ssl://electrum.blockstream.info:60002".to_string(),
},
#[cfg(feature = "esplora")]
esplora_opts: EsploraOpts {
- esplora: Some("https://blockstream.info/api/".to_string()),
- esplora_concurrency: 5,
+ esplora: None,
+ esplora_concurrency: 4,
},
#[cfg(feature = "compact_filters")]
compactfilter_opts: CompactFilterOpts{
- proxy: Some("127.0.0.1:9005".to_string()),
- user: Some("random_user".to_string()),
- passwd: Some("random_passwd".to_string()),
- address: "127.0.0.1:18444".to_string(),
+ address: vec!["127.0.0.1:18444".to_string(), "127.2.3.1:19695".to_string()],
conn_count: 4,
skip_blocks: 5,
},
+ #[cfg(any(feature="compact_filetrs", feature="electrum"))]
+ proxy_opts: ProxyOpts{
+ proxy: Some("127.0.0.1:9005".to_string()),
+ proxy_auth: Some(("random_user".to_string(), "random_passwd".to_string())),
+ retries: 5,
+ }
},
subcommand: WalletSubCommand::OfflineWalletSubCommand(GetNewAddress),
},
change_descriptor: None,
#[cfg(feature = "electrum")]
electrum_opts: ElectrumOpts {
- proxy: None,
- retries: 5,
timeout: None,
electrum: "ssl://electrum.blockstream.info:60002".to_string(),
},
},
#[cfg(feature = "compact_filters")]
compactfilter_opts: CompactFilterOpts{
- proxy: Some("127.0.0.1:9005".to_string()),
- user: Some("random_user".to_string()),
- passwd: Some("random_passwd".to_string()),
- address: "127.0.0.1:18444".to_string(),
+ address: vec!["127.0.0.1:18444".to_string()],
conn_count: 4,
- skip_blocks: 5,
+ skip_blocks: 0,
},
+ #[cfg(any(feature="compact_filetrs", feature="electrum"))]
+ proxy_opts: ProxyOpts{
+ proxy: None,
+ proxy_auth: None,
+ retries: 5,
+ }
},
subcommand: WalletSubCommand::OnlineWalletSubCommand(Sync {
max_addresses: Some(50)
change_descriptor: Some("wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)".to_string()),
#[cfg(feature = "electrum")]
electrum_opts: ElectrumOpts {
- proxy: None,
- retries: 5,
timeout: None,
electrum: "ssl://electrum.blockstream.info:60002".to_string(),
},
},
#[cfg(feature = "compact_filters")]
compactfilter_opts: CompactFilterOpts{
- proxy: Some("127.0.0.1:9005".to_string()),
- user: Some("random_user".to_string()),
- passwd: Some("random_passwd".to_string()),
- address: "127.0.0.1:18444".to_string(),
+ address: vec!["127.0.0.1:18444".to_string()],
conn_count: 4,
- skip_blocks: 5,
+ skip_blocks: 0,
},
+ #[cfg(any(feature="compact_filetrs", feature="electrum"))]
+ proxy_opts: ProxyOpts{
+ proxy: None,
+ proxy_auth: None,
+ retries: 5,
+ }
},
subcommand: WalletSubCommand::OfflineWalletSubCommand(CreateTx {
recipients: vec![(script1, 123456), (script2, 78910)],
change_descriptor: None,
#[cfg(feature = "electrum")]
electrum_opts: ElectrumOpts {
- proxy: None,
- retries: 5,
timeout: None,
electrum: "ssl://electrum.blockstream.info:60002".to_string(),
},
},
#[cfg(feature = "compact_filters")]
compactfilter_opts: CompactFilterOpts{
- proxy: Some("127.0.0.1:9005".to_string()),
- user: Some("random_user".to_string()),
- passwd: Some("random_passwd".to_string()),
- address: "127.0.0.1:18444".to_string(),
+ address: vec!["127.0.0.1:18444".to_string()],
conn_count: 4,
- skip_blocks: 5,
+ skip_blocks: 0,
},
+ #[cfg(any(feature="compact_filetrs", feature="electrum"))]
+ proxy_opts: ProxyOpts{
+ proxy: None,
+ proxy_auth: None,
+ retries: 5,
+ }
},
subcommand: WalletSubCommand::OnlineWalletSubCommand(Broadcast {
psbt: Some("cHNidP8BAEICAAAAASWhGE1AhvtO+2GjJHopssFmgfbq+WweHd8zN/DeaqmDAAAAAAD/////AQAAAAAAAAAABmoEAAECAwAAAAAAAAA=".to_string()),