keyfork-mnemonic-util: make clippy happy
This commit is contained in:
parent
91a6b845ba
commit
b5d2244091
|
@ -126,7 +126,7 @@ impl Display for Mnemonic {
|
||||||
.filter_map(|word| self.wordlist.get_word(word))
|
.filter_map(|word| self.wordlist.get_word(word))
|
||||||
.peekable();
|
.peekable();
|
||||||
while let Some(word) = iter.next() {
|
while let Some(word) = iter.next() {
|
||||||
f.write_str(&word)?;
|
f.write_str(word)?;
|
||||||
if iter.peek().is_some() {
|
if iter.peek().is_some() {
|
||||||
f.write_str(" ")?;
|
f.write_str(" ")?;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ impl FromStr for Mnemonic {
|
||||||
let word = wordlist
|
let word = wordlist
|
||||||
.0
|
.0
|
||||||
.iter()
|
.iter()
|
||||||
.position(|w| &w == word)
|
.position(|w| w == word)
|
||||||
.ok_or(MnemonicFromStrError::InvalidWord(index))?;
|
.ok_or(MnemonicFromStrError::InvalidWord(index))?;
|
||||||
usize_words.push(word);
|
usize_words.push(word);
|
||||||
for bit in 0..11 {
|
for bit in 0..11 {
|
||||||
|
@ -211,7 +211,7 @@ impl FromStr for Mnemonic {
|
||||||
let hash = hasher.finalize().to_vec();
|
let hash = hasher.finalize().to_vec();
|
||||||
|
|
||||||
for (i, bit) in checksum_bits.iter().enumerate() {
|
for (i, bit) in checksum_bits.iter().enumerate() {
|
||||||
if !hash[i / 8] & (1 << (7 - (i % 8))) == *bit as u8 {
|
if !hash[i / 8] & (1 << (7 - (i % 8))) == u8::from(*bit) {
|
||||||
return Err(MnemonicFromStrError::InvalidChecksum);
|
return Err(MnemonicFromStrError::InvalidChecksum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -246,6 +246,11 @@ impl Mnemonic {
|
||||||
Ok(unsafe { Self::from_raw_entropy(bytes, wordlist) })
|
Ok(unsafe { Self::from_raw_entropy(bytes, wordlist) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// # Safety
|
||||||
|
///
|
||||||
|
/// This function can potentially produce mnemonics that are not BIP-0039 compliant or can't
|
||||||
|
/// properly be encoded as a mnemonic. It is assumed the caller asserts the byte count is `% 4
|
||||||
|
/// == 0`.
|
||||||
pub unsafe fn from_raw_entropy(bytes: &[u8], wordlist: Arc<Wordlist>) -> Mnemonic {
|
pub unsafe fn from_raw_entropy(bytes: &[u8], wordlist: Arc<Wordlist>) -> Mnemonic {
|
||||||
Mnemonic {
|
Mnemonic {
|
||||||
entropy: bytes.to_vec(),
|
entropy: bytes.to_vec(),
|
||||||
|
|
Loading…
Reference in New Issue