From f78784973c054f56198f9b755b3c689dedff36b0 Mon Sep 17 00:00:00 2001 From: Dave Hrycyszyn Date: Mon, 29 Jul 2024 11:06:56 +0100 Subject: [PATCH] Closed off unnecessary public fn access in key generation --- side-node/src/bitcoin/keys.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/side-node/src/bitcoin/keys.rs b/side-node/src/bitcoin/keys.rs index 920e942..8852e28 100644 --- a/side-node/src/bitcoin/keys.rs +++ b/side-node/src/bitcoin/keys.rs @@ -12,12 +12,6 @@ use std::{ path::PathBuf, }; -pub fn make_mnemonic() -> String { - let mnemonic: GeneratedKey<_, miniscript::Segwitv0> = - Mnemonic::generate((WordCount::Words12, Language::English)).unwrap(); - mnemonic.to_string() -} - /// Write the mnemonic to a file in the node's side directory /// /// TODO: obviously spitting the mnemonic out to the console is not for production @@ -30,8 +24,15 @@ pub(crate) fn write(mnemonic_path: &PathBuf) -> Result<(), std::io::Error> { Ok(()) } +pub(crate) fn load_from_file(side_dir: &PathBuf) -> anyhow::Result { + let mnemonic_path = crate::utils::side_paths(side_dir.clone()).1; // TODO: this tuple stinks + let mnemonic_words = fs::read_to_string(mnemonic_path).expect("couldn't read bitcoin key file"); + println!("Creating extended key from mnemonic: {mnemonic_words}"); + generate_extended_key(mnemonic_words) +} + /// Creates Signet Bitcoin descriptors from a mnemonic -pub fn get(mnemonic_words: String) -> anyhow::Result { +fn generate_extended_key(mnemonic_words: String) -> anyhow::Result { let mnemonic = Mnemonic::parse(mnemonic_words).unwrap(); // Generate the extended key @@ -42,9 +43,8 @@ pub fn get(mnemonic_words: String) -> anyhow::Result { Ok(xkey) } -pub(crate) fn load_from_file(side_dir: &PathBuf) -> anyhow::Result { - let mnemonic_path = crate::utils::side_paths(side_dir.clone()).1; // TODO: this tuple stinks - let mnemonic_words = fs::read_to_string(mnemonic_path).expect("couldn't read bitcoin key file"); - println!("Creating wallet from mnemonic: {mnemonic_words}"); - get(mnemonic_words) +fn make_mnemonic() -> String { + let mnemonic: GeneratedKey<_, miniscript::Segwitv0> = + Mnemonic::generate((WordCount::Words12, Language::English)).unwrap(); + mnemonic.to_string() }