Using the keys::load_from_file function
This commit is contained in:
@@ -1,16 +1,14 @@
|
||||
use std::fs;
|
||||
|
||||
use bdk::{
|
||||
bitcoin::{psbt::PartiallySignedTransaction, secp256k1::PublicKey, Network, Transaction},
|
||||
blockchain::EsploraBlockchain,
|
||||
database::MemoryDatabase,
|
||||
keys::{bip39::Mnemonic, DerivableKey, ExtendedKey},
|
||||
keys::ExtendedKey,
|
||||
template::Bip84,
|
||||
wallet::AddressInfo,
|
||||
KeychainKind, SignOptions, SyncOptions, Wallet,
|
||||
};
|
||||
|
||||
use crate::utils;
|
||||
use crate::{bitcoin::keys, utils};
|
||||
|
||||
/// A client that uses Esplora to interact with the Bitcoin network.
|
||||
pub struct BitcoinClient {
|
||||
@@ -79,14 +77,10 @@ impl BitcoinClient {
|
||||
pub(crate) fn create(name: &str, network: Network) -> anyhow::Result<BitcoinClient> {
|
||||
let keys_dir = utils::home(name);
|
||||
|
||||
let mnemonic_path = crate::utils::side_paths(keys_dir).1; // TODO: this tuple stinks
|
||||
let words = fs::read_to_string(mnemonic_path).expect("couldn't read bitcoin key file");
|
||||
// let mnemonic_path = crate::utils::side_paths(keys_dir).1; // TODO: this tuple stinks
|
||||
// let words = fs::read_to_string(mnemonic_path).expect("couldn't read bitcoin key file");
|
||||
|
||||
tracing::info!("Creating {name}'s wallet from mnemonic: {words}");
|
||||
let xkey: ExtendedKey = Mnemonic::parse(words)
|
||||
.expect("couldn't parse mnemonic words")
|
||||
.into_extended_key()
|
||||
.expect("couldn't turn mnemonic into extended key");
|
||||
let xkey: ExtendedKey = keys::load_from_file(&keys_dir)?;
|
||||
|
||||
let xprv = xkey
|
||||
.into_xprv(Network::Signet)
|
||||
|
||||
Reference in New Issue
Block a user