[−][src]Crate bdk_cli
BDK Command line interface
This lib provides a structopt struct and enum that
parse global wallet options and wallet subcommand options needed for a wallet command line
interface.
See the bdk-cli example bin for how to use this module to create a simple command line
wallet application.
See WalletOpt for global wallet options and WalletSubCommand for supported sub-commands.
Example
// to get args from cli use: // let cli_opt = WalletOpt::from_args(); let cli_args = vec!["bdk-cli", "--network", "testnet", "--descriptor", "wpkh(tpubEBr4i6yk5nf5DAaJpsi9N2pPYBeJ7fZ5Z9rmN4977iYLCGco1VyjB9tvvuvYtfZzjD5A8igzgw3HeWeeKFmanHYqksqZXYXGsw5zjnj7KM9/*)", "sync", "--max_addresses", "50"]; let cli_opt = WalletOpt::from_iter(&cli_args); let network = cli_opt.network; let descriptor = cli_opt.descriptor.as_str(); let change_descriptor = cli_opt.change_descriptor.as_deref(); let database = MemoryDatabase::new(); let config = match cli_opt.esplora { Some(base_url) => AnyBlockchainConfig::Esplora(EsploraBlockchainConfig { base_url: base_url.to_string(), concurrency: Some(cli_opt.esplora_concurrency), }), None => AnyBlockchainConfig::Electrum(ElectrumBlockchainConfig { url: cli_opt.electrum, socks5: cli_opt.proxy, retry: 3, timeout: 5, }), }; let wallet = Wallet::new( descriptor, change_descriptor, network, database, AnyBlockchain::from_config(&config).unwrap(), ).unwrap(); let wallet = Arc::new(wallet); let result = bdk_cli::handle_wallet_subcommand(&wallet, cli_opt.subcommand).unwrap(); println!("{}", serde_json::to_string_pretty(&result).unwrap());
Re-exports
pub extern crate bdk; |
Structs
| WalletOpt | Wallet global options and sub-command |
Enums
| WalletSubCommand | Wallet sub-command |
Functions
| handle_wallet_subcommand | Execute a wallet sub-command with a given |