Skip to content

Commit

Permalink
gotta expose the seed for use
Browse files Browse the repository at this point in the history
  • Loading branch information
DougAnderson444 committed Sep 19, 2024
1 parent 8ec995d commit 3e37993
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions crates/seed-keeper-core/src/credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ impl Wallet {

encrypt(key, self.seed.clone())
}

/// Returns the seed, decrypted
pub fn seed(&self) -> &[u8] {
&self.seed
}
}

#[cfg(test)]
Expand Down Expand Up @@ -155,6 +160,8 @@ mod tests {
encrypted_seed: Some(encrypted_seed.clone()),
};

println!("{:?}", credentials);

let wallet = Wallet::new(credentials)?;

// Encrypt the seed
Expand Down Expand Up @@ -197,4 +204,30 @@ mod tests {

Ok(())
}

#[test]
fn test_works_long_enough() -> Result<(), error::Error> {
let json = r#"{"username":"username","password":"password","encrypted_seed":null}"#;

// it should deserialize the json
let credentials: Credentials = serde_json::from_str(json).map_err(|e| e.to_string())?;

assert_eq!(credentials.username.value(), "username");
assert_eq!(credentials.password.value(), "password");

Ok(())
}

#[test]
fn test_works_with_seed() -> Result<(), error::Error> {
let json = r#"{"username":"username","password":"password","encrypted_seed":[46,236,62,136,201,70,17,15,212,216,99,70,0,242,150,190,15,58,71,131,148,196,18,158,104,110,121,170,241,22,47,63,211,192,118,233,214,196,223,34]}"#;

// it should deserialize the json
let credentials: Credentials = serde_json::from_str(json).map_err(|e| e.to_string())?;

assert_eq!(credentials.username.value(), "username");
assert_eq!(credentials.password.value(), "password");

Ok(())
}
}

0 comments on commit 3e37993

Please sign in to comment.