Remove usage of try! macro, use ? instead (#3097)
We converted the major part of the code a while ago, but some occurences were left. It's a compiler warning on nightly already.
This commit is contained in:
committed by
Quentin Le Sceller
parent
b4e42bef8d
commit
8a7da89d47
@@ -122,7 +122,7 @@ impl BIP32Hasher for BIP32GrinHasher {
|
||||
b"IamVoldemort".to_owned()
|
||||
}
|
||||
fn init_sha512(&mut self, seed: &[u8]) {
|
||||
self.hmac_sha512 = HmacSha512::new_varkey(seed).expect("HMAC can take key of any size");;
|
||||
self.hmac_sha512 = HmacSha512::new_varkey(seed).expect("HMAC can take key of any size");
|
||||
}
|
||||
fn append_sha512(&mut self, value: &[u8]) {
|
||||
self.hmac_sha512.input(value);
|
||||
@@ -385,7 +385,7 @@ impl ExtendedPrivKey {
|
||||
Err(e) => return Err(Error::MnemonicError(e)),
|
||||
};
|
||||
let mut hasher = BIP32GrinHasher::new(is_floo);
|
||||
let key = r#try!(ExtendedPrivKey::new_master(secp, &mut hasher, &seed));
|
||||
let key = ExtendedPrivKey::new_master(secp, &mut hasher, &seed)?;
|
||||
Ok(key)
|
||||
}
|
||||
|
||||
@@ -716,7 +716,7 @@ mod tests {
|
||||
b"Bitcoin seed".to_owned()
|
||||
}
|
||||
fn init_sha512(&mut self, seed: &[u8]) {
|
||||
self.hmac_sha512 = HmacSha512::new_varkey(seed).expect("HMAC can take key of any size");;
|
||||
self.hmac_sha512 = HmacSha512::new_varkey(seed).expect("HMAC can take key of any size");
|
||||
}
|
||||
fn append_sha512(&mut self, value: &[u8]) {
|
||||
self.hmac_sha512.input(value);
|
||||
@@ -900,5 +900,4 @@ mod tests {
|
||||
serde_round_trip!(ChildNumber::from_hardened_idx(1));
|
||||
serde_round_trip!(ChildNumber::from_hardened_idx((1 << 31) - 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -72,7 +72,10 @@ pub fn to_entropy(mnemonic: &str) -> Result<Vec<u8>, Error> {
|
||||
}
|
||||
|
||||
// u11 vector of indexes for each word
|
||||
let mut indexes: Vec<u16> = r#try!(words.iter().map(|x| search(x)).collect());
|
||||
let mut indexes: Vec<u16> = words
|
||||
.iter()
|
||||
.map(|x| search(x))
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
let checksum_bits = words.len() / 3;
|
||||
let mask = ((1 << checksum_bits) - 1) as u8;
|
||||
let last = indexes.pop().unwrap();
|
||||
@@ -155,7 +158,7 @@ where
|
||||
Option<&'a str>: From<T>,
|
||||
{
|
||||
// make sure the mnemonic is valid
|
||||
r#try!(to_entropy(mnemonic));
|
||||
to_entropy(mnemonic)?;
|
||||
|
||||
let salt = ("mnemonic".to_owned() + Option::from(passphrase).unwrap_or("")).into_bytes();
|
||||
let data = mnemonic.as_bytes();
|
||||
|
||||
@@ -220,8 +220,8 @@ impl AsRef<[u8]> for Identifier {
|
||||
|
||||
impl ::std::fmt::Debug for Identifier {
|
||||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
|
||||
r#try!(write!(f, "{}(", stringify!(Identifier)));
|
||||
r#try!(write!(f, "{}", self.to_hex()));
|
||||
write!(f, "{}(", stringify!(Identifier))?;
|
||||
write!(f, "{}", self.to_hex())?;
|
||||
write!(f, ")")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user