From dba321560f29c0a7d7ec155c1dded346cf29db72 Mon Sep 17 00:00:00 2001 From: zhl Date: Thu, 23 Mar 2023 13:09:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/wallet/wallet_impl.rs | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/wallet/wallet_impl.rs b/src/wallet/wallet_impl.rs index cffea5a..ccab53f 100644 --- a/src/wallet/wallet_impl.rs +++ b/src/wallet/wallet_impl.rs @@ -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];