Skip to content

Commit d5ef778

Browse files
nepetcdecker
authored andcommitted
cli: Remove bip39 dependency
As we do not show bip39 mnenomics at the moment, there is no need to go the way through a mnemonic Signed-off-by: Peter Neuroth <[email protected]>
1 parent a833aeb commit d5ef778

File tree

4 files changed

+6
-15
lines changed

4 files changed

+6
-15
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/gl-cli/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ edition = "2021"
77
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
88

99
[dependencies]
10-
bip39 = "2.0.0"
1110
clap = { version = "4.5.4", features = ["derive"] }
1211
dirs = "5.0.1"
1312
env_logger = "0.11.3"

libs/gl-cli/src/scheduler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ async fn register_handler<P: AsRef<Path>>(
9292
}
9393
None => {
9494
// Generate a new seed and save it.
95-
let seed = util::generate_seed()?;
95+
let seed = util::generate_seed();
9696
util::write_seed(&seed_path, &seed)?;
9797
println!("Seed saved to {}", seed_path.display());
98-
seed
98+
seed.to_vec()
9999
}
100100
};
101101

libs/gl-cli/src/util.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use bip39::{self, Language, Mnemonic};
21
use dirs;
32
use gl_client::bitcoin::secp256k1::rand::{self, RngCore};
43
use gl_client::credentials;
@@ -16,15 +15,11 @@ pub const DEFAULT_GREENLIGHT_DIR: &str = "greenlight";
1615

1716
// -- Seed section
1817

19-
pub fn generate_seed() -> Result<Vec<u8>> {
20-
let mut entropy = [0u8; 32];
18+
pub fn generate_seed() -> [u8; 32] {
19+
let mut seed = [0u8; 32];
2120
let mut rng = rand::thread_rng();
22-
rng.fill_bytes(&mut entropy);
23-
24-
let mnemonic = Mnemonic::from_entropy_in(Language::English, &entropy)?;
25-
26-
// Return the first 32 bytes of the seed generated from the mnemonic
27-
Ok(mnemonic.to_seed("")[0..32].to_vec())
21+
rng.fill_bytes(&mut seed);
22+
seed
2823
}
2924

3025
pub fn read_seed(file_path: impl AsRef<Path>) -> Option<Vec<u8>> {
@@ -82,8 +77,6 @@ impl AsRef<Path> for DataDir {
8277

8378
#[derive(thiserror::Error, core::fmt::Debug)]
8479
pub enum UtilsError {
85-
#[error(transparent)]
86-
SeedError(#[from] bip39::Error),
8780
#[error(transparent)]
8881
IoError(#[from] std::io::Error),
8982
}

0 commit comments

Comments
 (0)