diff --git a/bitcoin/src/bip152.rs b/bitcoin/src/bip152.rs index 2b81a1cd..aa8b90dd 100644 --- a/bitcoin/src/bip152.rs +++ b/bitcoin/src/bip152.rs @@ -284,7 +284,7 @@ impl Decodable for BlockTransactionsRequest { // Since the number of indices ultimately represent transactions, // we can limit the number of indices to the maximum number of // transactions that would be allowed in a vector. - let byte_size = (nb_indexes as usize) + let byte_size = (nb_indexes) .checked_mul(mem::size_of::()) .ok_or(encode::Error::ParseFailed("Invalid length"))?; if byte_size > encode::MAX_VEC_SIZE { diff --git a/bitcoin/src/bip32.rs b/bitcoin/src/bip32.rs index dcb9dbc7..f631f4b7 100644 --- a/bitcoin/src/bip32.rs +++ b/bitcoin/src/bip32.rs @@ -627,7 +627,7 @@ impl ExtendedPrivKey { Network::Testnet | Network::Signet | Network::Regtest => [0x04, 0x35, 0x83, 0x94], }[..], ); - ret[4] = self.depth as u8; + ret[4] = self.depth; ret[5..9].copy_from_slice(&self.parent_fingerprint[..]); ret[9..13].copy_from_slice(&u32::from(self.child_number).to_be_bytes()); ret[13..45].copy_from_slice(&self.chain_code[..]); @@ -759,7 +759,7 @@ impl ExtendedPubKey { Network::Testnet | Network::Signet | Network::Regtest => [0x04u8, 0x35, 0x87, 0xCF], }[..], ); - ret[4] = self.depth as u8; + ret[4] = self.depth; ret[5..9].copy_from_slice(&self.parent_fingerprint[..]); ret[9..13].copy_from_slice(&u32::from(self.child_number).to_be_bytes()); ret[13..45].copy_from_slice(&self.chain_code[..]); diff --git a/bitcoin/src/blockdata/script.rs b/bitcoin/src/blockdata/script.rs index 7628da14..8cb8c76f 100644 --- a/bitcoin/src/blockdata/script.rs +++ b/bitcoin/src/blockdata/script.rs @@ -443,7 +443,7 @@ impl Script { pub fn is_empty(&self) -> bool { self.0.is_empty() } /// Returns the script data as a byte slice. - pub fn as_bytes(&self) -> &[u8] { &*self.0 } + pub fn as_bytes(&self) -> &[u8] { &self.0 } /// Returns a copy of the script data. pub fn to_bytes(&self) -> Vec { self.0.clone().into_vec() } diff --git a/bitcoin/src/blockdata/transaction.rs b/bitcoin/src/blockdata/transaction.rs index bf4c794b..1581587c 100644 --- a/bitcoin/src/blockdata/transaction.rs +++ b/bitcoin/src/blockdata/transaction.rs @@ -165,7 +165,7 @@ impl core::str::FromStr for OutPoint { return Err(ParseOutPointError::TooLong); } let find = s.find(':'); - if find == None || find != s.rfind(':') { + if find.is_none() || find != s.rfind(':') { return Err(ParseOutPointError::Format); } let colon = find.unwrap(); diff --git a/bitcoin/src/blockdata/witness.rs b/bitcoin/src/blockdata/witness.rs index 40311121..c559e580 100644 --- a/bitcoin/src/blockdata/witness.rs +++ b/bitcoin/src/blockdata/witness.rs @@ -179,7 +179,7 @@ impl Witness { /// Returns the number of elements this witness holds pub fn len(&self) -> usize { - self.witness_elements as usize + self.witness_elements } /// Returns the bytes required when this Witness is consensus encoded diff --git a/bitcoin/src/consensus/encode.rs b/bitcoin/src/consensus/encode.rs index 73b07f7e..20f9d306 100644 --- a/bitcoin/src/consensus/encode.rs +++ b/bitcoin/src/consensus/encode.rs @@ -423,7 +423,7 @@ impl Encodable for VarInt { }, _ => { w.emit_u8(0xFF)?; - (self.0 as u64).consensus_encode(w)?; + self.0.consensus_encode(w)?; Ok(9) }, } diff --git a/bitcoin/src/pow.rs b/bitcoin/src/pow.rs index f267d349..be0730e4 100644 --- a/bitcoin/src/pow.rs +++ b/bitcoin/src/pow.rs @@ -198,7 +198,7 @@ impl Target { size += 1; } - CompactTarget(compact | (size << 24) as u32) + CompactTarget(compact | (size << 24)) } /// Returns true if block hash is less than or equal to this [`Target`]. diff --git a/bitcoin/src/sign_message.rs b/bitcoin/src/sign_message.rs index f85795a1..6094e9a1 100644 --- a/bitcoin/src/sign_message.rs +++ b/bitcoin/src/sign_message.rs @@ -281,9 +281,8 @@ mod tests { let signature = super::MessageSignature::from_base64(signature_base64).expect("message signature"); - let pubkey = - PublicKey::from_slice(&::base64::decode(&pubkey_base64).expect("base64 string")) - .expect("pubkey slice"); + let pubkey = PublicKey::from_slice(&base64::decode(pubkey_base64).expect("base64 string")) + .expect("pubkey slice"); let p2pkh = Address::p2pkh(&pubkey, Network::Bitcoin); assert_eq!(signature.is_signed_by_address(&secp, &p2pkh, msg_hash), Ok(false));