MCPcopy Create free account
hub / github.com/bitcoindevkit/bdk-cli / load_wallet_config

Function load_wallet_config

src/utils.rs:639–665  ·  view source on GitHub ↗
(
    home_dir: &Path,
    wallet_name: &str,
)

Source from the content-addressed store, hash-verified

637}
638
639pub fn load_wallet_config(
640 home_dir: &Path,
641 wallet_name: &str,
642) -> Result<(WalletOpts, Network), Error> {
643 let config = WalletConfig::load(home_dir)?.ok_or(Error::Generic(format!(
644 "No config found for wallet {wallet_name}",
645 )))?;
646
647 let wallet_opts = config.get_wallet_opts(wallet_name)?;
648 let wallet_config = config
649 .wallets
650 .get(wallet_name)
651 .ok_or(Error::Generic(format!(
652 "Wallet '{wallet_name}' not found in config"
653 )))?;
654
655 let network = match wallet_config.network.as_str() {
656 "bitcoin" => Ok(Network::Bitcoin),
657 "testnet" => Ok(Network::Testnet),
658 "regtest" => Ok(Network::Regtest),
659 "signet" => Ok(Network::Signet),
660 "testnet4" => Ok(Network::Testnet4),
661 _ => Err(Error::Generic("Invalid network in config".to_string())),
662 }?;
663
664 Ok((wallet_opts, network))
665}

Callers 1

handle_commandFunction · 0.85

Calls 1

get_wallet_optsMethod · 0.80

Tested by

no test coverage detected