Made the wallet's Network configurable

This commit is contained in:
Dave Hrycyszyn
2024-06-25 15:05:33 +01:00
parent 7effe9455f
commit a6105cf2bf
2 changed files with 6 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
use std::{collections::BTreeSet, fs, io::Write, str::FromStr};
use std::{collections::BTreeSet, fs, io::Write};
use bdk::keys::bip39::Mnemonic;
use bdk_esplora::{
@@ -20,6 +20,7 @@ use crate::utils;
const STOP_GAP: usize = 50;
const PARALLEL_REQUESTS: usize = 5;
/// A wallet that uses the Esplora client to interact with the Bitcoin network.
pub struct EsploraWallet {
wallet: Wallet,
db: Store<KeychainKind, ConfirmationTimeHeightAnchor>,
@@ -124,8 +125,8 @@ impl EsploraWallet {
}
}
/// Creates a Bitcoin Signet descriptor wallet with the mnemonic in the given user directory.
pub(crate) fn create_wallet(name: &str) -> anyhow::Result<EsploraWallet> {
/// Creates a Bitcoin descriptor wallet with the mnemonic in the given user directory.
pub(crate) fn create_wallet(name: &str, network: Network) -> anyhow::Result<EsploraWallet> {
let keys_dir = utils::home(name);
let mnemonic_path = crate::utils::side_paths(keys_dir).1; // TODO: this tuple stinks
@@ -157,7 +158,7 @@ pub(crate) fn create_wallet(name: &str) -> anyhow::Result<EsploraWallet> {
&external_descriptor,
&internal_descriptor,
changeset,
Network::Signet,
network,
)
.expect("problem setting up wallet");