(
home_dir: &Path,
wallet_name: &str,
)
| 637 | } |
| 638 | |
| 639 | pub 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 | } |
no test coverage detected