Made the wallet's Network configurable
This commit is contained in:
@@ -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");
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::bitcoin::clients;
|
||||
/// Also, it very handily works with the mutinynet.com esplora server, which is configured
|
||||
/// with 30 second block times.
|
||||
pub(crate) async fn run() -> Result<(), anyhow::Error> {
|
||||
let mut dave = clients::esplora::create_wallet("dave")?;
|
||||
let mut dave = clients::esplora::create_wallet("dave", Network::Signet)?;
|
||||
|
||||
let _next_address = dave.next_unused_address()?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user