//!
//! This module defines all the bdk-cli commands using [structopt]
+#![allow(clippy::large_enum_variant)]
use structopt::clap::AppSettings;
+
use structopt::StructOpt;
use bdk::bitcoin::util::bip32::{DerivationPath, ExtendedPrivKey};
default_value = "testnet"
)]
pub network: Network,
+ /// Sets the wallet data directory.
+ /// Default value : "~/.bdk-bitcoin
+ #[structopt(name = "DATADIR", short = "d", long = "datadir")]
+ pub datadir: Option<std::path::PathBuf>,
+ /// Top level cli sub-command
#[structopt(subcommand)]
pub subcommand: CliSubCommand,
}
#[derive(Debug, StructOpt, Clone, PartialEq)]
#[structopt(rename_all = "snake")]
pub enum CliSubCommand {
+ /// Node operation subcommands
+ ///
+ /// These commands can be used to control the backend bitcoin-core node
+ /// launched automatically with the `regtest-*` feature sets. The commands issues
+ /// bitcoin-cli rpc calls on the demon, in the background.
+ ///
+ /// Feel free to open feature-request in https://github.com/bitcoindevkit/bdk-cli
+ /// if you need extra rpc calls not covered in the command list.
+ #[cfg(feature = "regtest-node")]
+ #[structopt(long_about = "Regtest Node mode")]
+ Node {
+ #[structopt(subcommand)]
+ subcommand: NodeSubCommand,
+ },
/// Wallet Operations
///
/// bdk-cli wallet operations includes all the basic wallet level tasks.
},
}
+#[derive(Debug, StructOpt, Clone, PartialEq)]
+#[structopt(rename_all = "lower")]
+#[cfg(any(feature = "regtest-node"))]
+pub enum NodeSubCommand {
+ /// Get info
+ GetInfo,
+ /// Get new address from node's test wallet
+ GetNewAddress,
+ /// Generate given number of blocks and fund the internal wallet with coinbases.
+ Generate { block_num: u64 },
+ /// Get Wallet balance
+ GetBalance,
+ /// Send to an external wallet address
+ SendToAddress { address: String, amount: u64 },
+ /// Execute any bitcoin-cli commands
+ #[structopt(external_subcommand)]
+ BitcoinCli(Vec<String>),
+}
+
#[derive(Debug, StructOpt, Clone, PartialEq)]
pub enum WalletSubCommand {
#[cfg(any(
#[cfg(feature = "repl")]
#[derive(Debug, StructOpt, Clone, PartialEq)]
-#[structopt(global_settings =&[AppSettings::NoBinaryName])]
+#[structopt(global_settings =&[AppSettings::NoBinaryName], rename_all = "lower")]
pub enum ReplSubCommand {
- #[cfg(any(
- feature = "electrum",
- feature = "esplora",
- feature = "compact_filters",
- feature = "rpc"
- ))]
- #[structopt(flatten)]
- OnlineWalletSubCommand(OnlineWalletSubCommand),
- #[structopt(flatten)]
- OfflineWalletSubCommand(OfflineWalletSubCommand),
- #[structopt(flatten)]
- KeySubCommand(KeySubCommand),
+ /// Execute wallet Commands
+ Wallet {
+ #[structopt(subcommand)]
+ subcommand: WalletSubCommand,
+ },
+ /// Execute Key Commands
+ Key {
+ #[structopt(subcommand)]
+ subcommand: KeySubCommand,
+ },
+ /// Execute Node Commands
+ #[cfg(feature = "regtest-node")]
+ Node {
+ #[structopt(subcommand)]
+ subcommand: NodeSubCommand,
+ },
/// Exit REPL loop
Exit,
}
let expected_cli_opts = CliOpts {
network: Network::Bitcoin,
+ datadir: None,
subcommand: CliSubCommand::Wallet {
wallet_opts: WalletOpts {
wallet: None,
let expected_cli_opts = CliOpts {
network: Network::Testnet,
+ datadir: None,
subcommand: CliSubCommand::Wallet {
wallet_opts: WalletOpts {
wallet: None,
let expected_cli_opts = CliOpts {
network: Network::Bitcoin,
+ datadir: None,
subcommand: CliSubCommand::Wallet {
wallet_opts: WalletOpts {
wallet: None,
let expected_cli_opts = CliOpts {
network: Network::Bitcoin,
+ datadir: None,
subcommand: CliSubCommand::Wallet {
wallet_opts: WalletOpts {
wallet: None,
let expected_cli_opts = CliOpts {
network: Network::Bitcoin,
+ datadir: None,
subcommand: CliSubCommand::Wallet {
wallet_opts: WalletOpts {
wallet: None,
let expected_cli_opts = CliOpts {
network: Network::Bitcoin,
+ datadir: None,
subcommand: CliSubCommand::Wallet {
wallet_opts: WalletOpts {
wallet: None,
let expected_cli_opts = CliOpts {
network: Network::Testnet,
+ datadir: None,
subcommand: CliSubCommand::Wallet {
wallet_opts: WalletOpts {
wallet: None,
let expected_cli_opts = CliOpts {
network: Network::Testnet,
+ datadir: None,
subcommand: CliSubCommand::Wallet {
wallet_opts: WalletOpts {
wallet: None,
let expected_cli_opts = CliOpts {
network: Network::Testnet,
+ datadir: None,
subcommand: CliSubCommand::Wallet {
wallet_opts: WalletOpts {
wallet: None,
let expected_cli_opts = CliOpts {
network: Network::Testnet,
+ datadir: None,
subcommand: CliSubCommand::Wallet {
wallet_opts: WalletOpts {
wallet: None,
let expected_cli_opts = CliOpts {
network: Network::Testnet,
+ datadir: None,
subcommand: CliSubCommand::Compile {
policy: "thresh(3,pk(Alice),pk(Bob),pk(Carol),older(2))".to_string(),
script_type: "sh-wsh".to_string(),
let expected_cli_opts = CliOpts {
network: Network::Bitcoin,
+ datadir: None,
subcommand: CliSubCommand::ExternalReserves {
message,
psbt,