Removed deprecated keystore code.

This commit is contained in:
Revertron
2021-05-19 17:59:19 +02:00
parent 4e96eeed59
commit 7c38ee915f
3 changed files with 10 additions and 49 deletions
+10 -38
View File
@@ -73,51 +73,23 @@ impl Keystore {
let path = Path::new(filename);
match fs::read(&path) {
Ok(key) => {
return match key.len() {
32 => {
let mut keystore = Keystore::from_random_bytes(key.as_slice());
keystore.path = path.to_str().unwrap().to_owned();
keystore.old = true;
match toml::from_slice::<Keys>(key.as_slice()) {
Ok(keys) => {
let secret = SecretKey::from_bytes(&from_hex(&keys.signing.secret).unwrap()).unwrap();
let public = PublicKey::from_bytes(&from_hex(&keys.signing.public).unwrap()).unwrap();
let keypair = Keypair { secret, public };
let crypto_box = CryptoBox::from_strings(&keys.encryption.secret, &keys.encryption.public);
let keystore = Keystore { keypair, hash: RefCell::new(Bytes::default()), path: String::from(filename), crypto_box, old: false };
let bytes = Bytes::from_bytes(&keystore.keypair.public.to_bytes());
if check_public_key_strength(&bytes, KEYSTORE_DIFFICULTY) {
warn!("Loaded key from OLD format! Please, resave it!");
Some(keystore)
} else {
None
}
}
64 => {
let mut keystore = Self::from_bytes(key.as_slice());
keystore.path = path.to_str().unwrap().to_owned();
keystore.old = true;
let bytes = Bytes::from_bytes(&keystore.keypair.public.to_bytes());
if check_public_key_strength(&bytes, KEYSTORE_DIFFICULTY) {
warn!("Loaded key from OLD format! Please, resave it!");
Some(keystore)
} else {
None
}
}
_ => {
match toml::from_slice::<Keys>(key.as_slice()) {
Ok(keys) => {
let secret = SecretKey::from_bytes(&from_hex(&keys.signing.secret).unwrap()).unwrap();
let public = PublicKey::from_bytes(&from_hex(&keys.signing.public).unwrap()).unwrap();
let keypair = Keypair { secret, public };
let crypto_box = CryptoBox::from_strings(&keys.encryption.secret, &keys.encryption.public);
let keystore = Keystore { keypair, hash: RefCell::new(Bytes::default()), path: String::from(filename), crypto_box, old: false };
let bytes = Bytes::from_bytes(&keystore.keypair.public.to_bytes());
if check_public_key_strength(&bytes, KEYSTORE_DIFFICULTY) {
Some(keystore)
} else {
None
}
}
Err(e) => {
error!("Error loading keystore from {}: {}", filename, e);
None
}
}
Err(e) => {
error!("Error loading keystore from {}: {}", filename, e);
None
}
}
}
-7
View File
@@ -131,13 +131,6 @@ fn main() {
}
}
}
} else {
match Keystore::from_file(&settings.key_file, "") {
None => { warn!("Error loading keyfile from {}", &settings.key_file); }
Some(keystore) => {
keys.push(keystore);
}
}
}
let context = Context::new(env!("CARGO_PKG_VERSION").to_owned(), settings, keys, chain);
let context: Arc<Mutex<Context>> = Arc::new(Mutex::new(context));
-4
View File
@@ -11,9 +11,6 @@ use crate::Bytes;
pub struct Settings {
#[serde(default)]
pub origin: String,
#[serde(default)]
#[deprecated]
pub key_file: String,
#[serde(default = "default_key_files")]
pub key_files: Vec<String>,
#[serde(default = "default_check_blocks")]
@@ -56,7 +53,6 @@ impl Default for Settings {
fn default() -> Self {
Self {
origin: String::from("0000001D2A77D63477172678502E51DE7F346061FF7EB188A2445ECA3FC0780E"),
key_file: String::default(),
key_files: default_key_files(),
check_blocks: default_check_blocks(),
net: Net::default(),