优化代码

This commit is contained in:
zhl 2023-03-23 13:09:57 +08:00
parent 8414b9307a
commit dba321560f

View File

@ -123,19 +123,13 @@ impl Wallet {
let key_str_0: &str = &self.master_key;
let key0 = BigInt::parse_bytes(&key_str_0.as_bytes(), 16).unwrap();
let kp0: (usize, BigInt) = (1, key0);
let i: usize;
let key_str_1: &str;
if let Some(val) = &self.second_key {
i = 2;
key_str_1 = val;
} else if let Some(val) = &self.backup_key {
i = 3;
key_str_1 = val;
} else {
println!("error");
i = 2;
key_str_1 = "";
}
let (i, key_str_1) = match (&self.second_key, &self.backup_key) {
(Some(val), _) => (2, val),
(_, Some(val)) => (3, val),
_ => {
panic!("error generate key")
}
};
let key1 = BigInt::parse_bytes(&key_str_1.as_bytes(), 16).unwrap();
let kp1 = (i, key1);
let _tmp = vec![kp0, kp1];