Expand description
BDK command line interface
This lib provides structopt
structs and enums that parse CLI options and sub-commands from
the command line or from a String
vector that can be used to access features of the bdk
library. Functions are also provided to handle subcommands and options and provide results via
the bdk
lib.
See the bdk-cli
example bin for how to use this lib to create a simple command line
application that demonstrates bdk
wallet and key management features.
See CliOpts
for global cli options and CliSubCommand
for supported top level sub-commands.
Example
// to get args from cli use:
// let cli_opts = CliOpts::from_args();
let cli_args = vec!["bdk-cli", "--network", "testnet", "wallet", "--descriptor",
"wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)",
"sync"];
let cli_opts = CliOpts::from_iter(&cli_args);
let network = cli_opts.network;
if let CliSubCommand::Wallet {
wallet_opts,
subcommand: WalletSubCommand::OnlineWalletSubCommand(online_subcommand)
} = cli_opts.subcommand {
let descriptor = wallet_opts.descriptor.as_str();
let change_descriptor = wallet_opts.change_descriptor.as_deref();
let database = MemoryDatabase::new();
let blockchain_config = AnyBlockchainConfig::Electrum(ElectrumBlockchainConfig {
url: wallet_opts.electrum_opts.server.clone(),
socks5: wallet_opts.proxy_opts.proxy.clone(),
retry: wallet_opts.proxy_opts.retries,
timeout: wallet_opts.electrum_opts.timeout,
stop_gap: wallet_opts.electrum_opts.stop_gap,
});
let blockchain = AnyBlockchain::from_config(&blockchain_config).expect("blockchain");
let wallet = Wallet::new(
descriptor,
change_descriptor,
network,
database,
).expect("wallet");
let result = bdk_cli::handle_online_wallet_subcommand(&wallet, &blockchain, online_subcommand).expect("result");
println!("{}", serde_json::to_string_pretty(&result).unwrap());
}
Re-exports
Structs
Global options
Electrum options
Proxy Server options
Wallet options
Enums
CLI sub-commands
Key sub-command
Offline Wallet sub-command
Online Wallet sub-command
Wallet sub-commands
Functions
Execute the miniscript compiler sub-command
Execute a key sub-command
Execute an offline wallet sub-command
Execute an online wallet sub-command