#[cfg(feature = "rpc")]
/// Sets the rpc basic authentication.
#[arg(
- env = "USER:PASSWD",
+ env = "RPC_BASIC_AUTH",
short = 'a',
long,
value_parser = parse_proxy_auth,
)));
}
#[cfg(any(feature = "electrum", feature = "esplora"))]
- if self.proxy_opts.proxy_auth.is_some() {
- return Err(Error::Generic(format!(
- "The {_backend} backend does not support --proxy_auth."
- )));
- }
- #[cfg(any(feature = "electrum", feature = "esplora"))]
- if self.proxy_opts.timeout.is_some() {
- return Err(Error::Generic(format!(
- "The {_backend} backend does not support --timeout."
- )));
+ {
+ if self.proxy_opts.proxy_auth.is_some() {
+ return Err(Error::Generic(format!(
+ "The {_backend} backend does not support --proxy_auth."
+ )));
+ }
+ if self.proxy_opts.timeout.is_some() {
+ return Err(Error::Generic(format!(
+ "The {_backend} backend does not support --timeout."
+ )));
+ }
}
Ok(())
}
#[cfg(feature = "cbf")]
pub(crate) fn reject_proxy_auth(&self, _backend: &str) -> Result<(), Error> {
#[cfg(any(feature = "electrum", feature = "esplora"))]
- if self.proxy_opts.proxy_auth.is_some() {
- return Err(Error::Generic(format!(
- "The {_backend} backend does not support --proxy_auth."
- )));
- }
- #[cfg(any(feature = "electrum", feature = "esplora"))]
- if self.proxy_opts.timeout.is_some() {
- return Err(Error::Generic(format!(
- "The {_backend} backend does not support --timeout."
- )));
+ {
+ if self.proxy_opts.proxy_auth.is_some() {
+ return Err(Error::Generic(format!(
+ "The {_backend} backend does not support --proxy_auth."
+ )));
+ }
+ if self.proxy_opts.timeout.is_some() {
+ return Err(Error::Generic(format!(
+ "The {_backend} backend does not support --timeout."
+ )));
+ }
}
Ok(())
}
#[derive(Debug, Args, Clone, PartialEq, Eq)]
pub struct ProxyOpts {
/// Sets the SOCKS5 proxy for a blockchain client.
- #[arg(env = "PROXY_ADDRS:PORT", long = "proxy")]
+ #[arg(env = "PROXY_ADDRS_PORT", long = "proxy")]
pub proxy: Option<String>,
/// Sets the SOCKS5 proxy credential.
#[cfg(any(feature = "electrum", feature = "esplora"))]
- #[arg(env = "PROXY_USER:PASSWD", long="proxy_auth", value_parser = parse_proxy_auth)]
+ #[arg(env = "PROXY_USER_PASSWD", long="proxy_auth", value_parser = parse_proxy_auth)]
pub proxy_auth: Option<(String, String)>,
/// Sets the SOCKS5 proxy retries for the blockchain client.
/// Creates a new unsigned transaction from DNS payment instructions.
#[derive(Parser, Debug, Clone, PartialEq)]
pub struct CreateDnsTxCommand {
- #[arg(env = "ADDRESS:SAT", long = "to", value_parser = parse_recipient)]
+ #[arg(env = "ADDRESS_SAT", long = "to", value_parser = parse_recipient)]
pub recipients: Vec<(ScriptBuf, u64)>,
#[arg(long = "to_dns", value_parser = parse_dns_recipient)]
pub dns_recipients: Vec<(String, u64)>,
pub enable_rbf: bool,
#[arg(long = "offline_signer")]
pub offline_signer: bool,
- #[arg(env = "MUST_SPEND_TXID:VOUT", long = "utxos", value_parser = parse_outpoint)]
+ #[arg(env = "MUST_SPEND_TXID_VOUT", long = "utxos", value_parser = parse_outpoint)]
pub utxos: Option<Vec<OutPoint>>,
- #[arg(env = "CANT_SPEND_TXID:VOUT", long = "unspendable", value_parser = parse_outpoint)]
+ #[arg(env = "CANT_SPEND_TXID_VOUT", long = "unspendable", value_parser = parse_outpoint)]
pub unspendable: Option<Vec<OutPoint>>,
#[arg(env = "SATS_VBYTE", short = 'f', long = "fee_rate", value_parser = parse_fee_rate)]
pub fee_rate: Option<FeeRate>,
#[derive(Debug, Parser, Clone, PartialEq)]
pub struct CreateTxCommand {
/// Adds a recipient to the transaction.
- #[arg(env = "ADDRESS:SAT", long = "to", required = true, value_parser = parse_recipient)]
+ #[arg(env = "ADDRESS_SAT", long = "to", required = true, value_parser = parse_recipient)]
pub recipients: Vec<(ScriptBuf, u64)>,
/// Sends all the funds (or all the selected utxos). Requires only one recipient with value 0.
pub offline_signer: bool,
/// Selects which utxos *must* be spent.
- #[arg(env = "MUST_SPEND_TXID:VOUT", long = "utxos", value_parser = parse_outpoint)]
+ #[arg(env = "MUST_SPEND_TXID_VOUT", long = "utxos", value_parser = parse_outpoint)]
pub utxos: Option<Vec<OutPoint>>,
/// Marks a utxo as unspendable.
- #[arg(env = "CANT_SPEND_TXID:VOUT", long = "unspendable", value_parser = parse_outpoint)]
+ #[arg(env = "CANT_SPEND_TXID_VOUT", long = "unspendable", value_parser = parse_outpoint)]
pub unspendable: Option<Vec<OutPoint>>,
/// Fee rate to use in sat/vbyte.
/// Adds a recipient to the transaction.
// Clap Doesn't support complex vector parsing https://github.com/clap-rs/clap/issues/1704.
// Address and amount parsing is done at run time in handler function.
- #[arg(env = "ADDRESS:SAT", long = "to", required = false, value_parser = parse_recipient)]
+ #[arg(env = "ADDRESS_SAT", long = "to", required = false, value_parser = parse_recipient)]
pub recipients: Option<Vec<(ScriptBuf, u64)>>,
/// Parse silent payment recipients
#[arg(long = "to-sp", required = true, value_parser = parse_sp_code_value_pairs)]
#[arg(long = "offline_signer")]
pub offline_signer: bool,
/// Selects which utxos *must* be spent.
- #[arg(env = "MUST_SPEND_TXID:VOUT", long = "utxos", value_parser = parse_outpoint)]
+ #[arg(env = "MUST_SPEND_TXID_VOUT", long = "utxos", value_parser = parse_outpoint)]
pub utxos: Option<Vec<OutPoint>>,
/// Marks a utxo as unspendable.
- #[arg(env = "CANT_SPEND_TXID:VOUT", long = "unspendable", value_parser = parse_outpoint)]
+ #[arg(env = "CANT_SPEND_TXID_VOUT", long = "unspendable", value_parser = parse_outpoint)]
pub unspendable: Option<Vec<OutPoint>>,
/// Fee rate to use in sat/vbyte.
#[arg(env = "SATS_VBYTE", short = 'f', long = "fee_rate", value_parser = parse_fee_rate)]
pub offline_signer: bool,
/// Selects which utxos *must* be added to the tx. Unconfirmed utxos cannot be used.
- #[arg(env = "MUST_SPEND_TXID:VOUT", long = "utxos", value_parser = parse_outpoint)]
+ #[arg(env = "MUST_SPEND_TXID_VOUT", long = "utxos", value_parser = parse_outpoint)]
pub utxos: Option<Vec<OutPoint>>,
/// Marks an utxo as unspendable, in case more inputs are needed to cover the extra fees.
- #[arg(env = "CANT_SPEND_TXID:VOUT", long = "unspendable", value_parser = parse_outpoint)]
+ #[arg(env = "CANT_SPEND_TXID_VOUT", long = "unspendable", value_parser = parse_outpoint)]
pub unspendable: Option<Vec<OutPoint>>,
/// The new targeted fee rate in sat/vbyte.
pub fn build_base_cmd(&self) -> Command {
let mut cmd = Command::cargo_bin("bdk-cli").expect("bdk-cli binary must compile");
- cmd.arg("--network").arg(&self.network);
+ cmd.args(["--network", &self.network]);
if let Some(dir) = &self.datadir {
cmd.arg("--datadir").arg(dir);
}
if let Some(url) = &self.server_url {
- cmd.arg("--server").arg(url);
+ cmd.args(["--server", url]);
}
cmd
cli.build_base_cmd()
.arg("wallet")
- .arg("--wallet")
- .arg(wallet_name)
+ .args(["--wallet", wallet_name])
.arg("config")
- .arg("--ext-descriptor")
- .arg(ext_desc)
- .arg("--int-descriptor")
- .arg(int_desc)
- .arg("--client-type")
- .arg("rpc")
- .arg("--database-type")
- .arg("sqlite")
- .arg("--url")
- .arg("http://localhost:18443")
+ .args(["--ext-descriptor", ext_desc])
+ .args(["--int-descriptor", int_desc])
+ .args(["--client-type", "rpc"])
+ .args(["--database-type", "sqlite"])
+ .args(["--url", "http://localhost:18443"])
.assert()
.success();
}
let mut cmd_init = cli.build_base_cmd();
cmd_init
.arg("wallet")
- .arg("--wallet")
- .arg(wallet_name)
+ .args(["--wallet", wallet_name])
.arg("config")
- .arg("--ext-descriptor")
- .arg(ext_desc)
- .arg("--int-descriptor")
- .arg(int_desc)
- .arg("--client-type")
- .arg(client_type)
- .arg("--database-type")
- .arg(db)
- .arg("--url")
- .arg(url);
+ .args(["--ext-descriptor", ext_desc])
+ .args(["--int-descriptor", int_desc])
+ .args(["--client-type", client_type])
+ .args(["--database-type", db])
+ .args(["--url", url]);
cmd_init.assert().success();
cli.build_base_cmd()
.arg("wallet")
- .arg("--wallet")
- .arg("secret_wallet")
+ .args(["--wallet", "secret_wallet"])
.arg("config")
.arg("--ext-descriptor")
.arg(priv_desc["external"].as_str().unwrap())
.arg("--int-descriptor")
.arg(priv_desc["internal"].as_str().unwrap())
- .arg("--client-type")
- .arg("rpc")
- .arg("--database-type")
- .arg("sqlite")
- .arg("--url")
- .arg("http://localhost:18443")
+ .args(["--client-type", "rpc"])
+ .args(["--database-type", "sqlite"])
+ .args(["--url", "http://localhost:18443"])
.assert()
.success()
.stderr(predicate::str::contains("PRIVATE KEYS"));
let mut cmd_init = cli.build_base_cmd();
cmd_init
.arg("wallet")
- .arg("--wallet")
- .arg(WALLET_NAME)
+ .args(["--wallet", WALLET_NAME])
.arg("config")
- .arg("--ext-descriptor")
- .arg(ext_desc)
- .arg("--int-descriptor")
- .arg(int_desc)
- .arg("--client-type")
- .arg(client_type)
- .arg("--database-type")
- .arg(db)
- .arg("--url")
- .arg(url);
+ .args(["--ext-descriptor", ext_desc])
+ .args(["--int-descriptor", int_desc])
+ .args(["--client-type", client_type])
+ .args(["--database-type", db])
+ .args(["--url", url]);
(cli, cmd_init)
}
fn save_config(cli: &BdkCli, wallet: &str, ext: &str, int: Option<&str>) -> Command {
let mut cmd = cli.build_base_cmd();
cmd.arg("wallet")
- .arg("--wallet")
- .arg(wallet)
+ .args(["--wallet", wallet])
.arg("config")
- .arg("--ext-descriptor")
- .arg(ext)
- .arg("--database-type")
- .arg("sqlite");
+ .args(["--ext-descriptor", ext])
+ .args(["--database-type", "sqlite"]);
if let Some(int) = int {
cmd.arg("--int-descriptor").arg(int);
}
let mut cmd_init = cli.build_base_cmd();
cmd_init
.arg("wallet")
- .arg("--wallet")
- .arg(WALLET_NAME)
+ .args(["--wallet", WALLET_NAME])
.arg("config")
- .arg("--ext-descriptor")
- .arg(ext_desc)
- .arg("--int-descriptor")
- .arg(int_desc)
- .arg("--client-type")
- .arg("electrum")
- .arg("--database-type")
- .arg("sqlite")
- .arg("--url")
- .arg(server_url);
+ .args(["--ext-descriptor", ext_desc])
+ .args(["--int-descriptor", int_desc])
+ .args(["--client-type", "electrum"])
+ .args(["--database-type", "sqlite"])
+ .args(["--url", server_url]);
(cli, cmd_init, env)
}
.unwrap();
cli.build_base_cmd()
.arg("wallet")
- .arg("--wallet")
- .arg(WALLET_NAME)
+ .args(["--wallet", WALLET_NAME])
.arg("config")
- .arg("--ext-descriptor")
- .arg(ext_desc)
- .arg("--int-descriptor")
- .arg(int_desc)
- .arg("--client-type")
- .arg("electrum")
- .arg("--database-type")
- .arg("sqlite")
- .arg("--url")
- .arg(server_url)
+ .args(["--ext-descriptor", ext_desc])
+ .args(["--int-descriptor", int_desc])
+ .args(["--client-type", "electrum"])
+ .args(["--database-type", "sqlite"])
+ .args(["--url", server_url])
.assert()
.success();
#[cfg(any(feature = "rpc", feature = "cbf"))]
use predicates::prelude::*;
use serde_json::Value;
- #[cfg(any(feature = "electrum", feature = "esplora"))]
- use std::net::{TcpListener, TcpStream};
- #[cfg(any(feature = "electrum", feature = "esplora"))]
- use std::sync::mpsc::{Receiver, channel};
- #[cfg(any(feature = "electrum", feature = "esplora"))]
- use std::thread;
use std::time::Duration;
use tempfile::TempDir;
+ #[cfg(any(feature = "electrum", feature = "esplora"))]
+ use {
+ std::net::{TcpListener, TcpStream},
+ std::sync::mpsc::{Receiver, channel},
+ std::thread,
+ };
static WALLET_NAME: &str = "proxy_test_wallet";
let mut cmd = cli.build_base_cmd();
cmd.arg("wallet")
- .arg("--wallet")
- .arg(WALLET_NAME)
+ .args(["--wallet", WALLET_NAME])
.arg("config")
- .arg("--ext-descriptor")
- .arg(ext_desc)
- .arg("--int-descriptor")
- .arg(int_desc)
- .arg("--client-type")
- .arg(client_type)
- .arg("--database-type")
- .arg("sqlite")
- .arg("--url")
- .arg(url);
+ .args(["--ext-descriptor", ext_desc])
+ .args(["--int-descriptor", int_desc])
+ .args(["--client-type", client_type])
+ .args(["--database-type", "sqlite"])
+ .args(["--url", url]);
if let Some(proxy) = proxy_addr {
cmd.arg("--proxy").arg(proxy);
}
let mut cmd = cli.build_base_cmd();
cmd.arg("wallet")
- .arg("--wallet")
- .arg(WALLET_NAME)
+ .args(["--wallet", WALLET_NAME])
.arg("config")
.arg("--ext-descriptor")
.arg(public["external"].as_str().unwrap())
.arg("--int-descriptor")
.arg(public["internal"].as_str().unwrap())
- .arg("--client-type")
- .arg(client_type)
- .arg("--database-type")
- .arg("sqlite");
+ .args(["--client-type", client_type])
+ .args(["--database-type", "sqlite"]);
// `--url` is required whenever electrum, esplora or rpc is built, no matter
// which `--client-type` is chosen; it does not exist at all otherwise.
#[cfg(any(feature = "electrum", feature = "esplora", feature = "rpc"))]