Remove additional reference

Clippy emits:

  warning: this expression creates a reference which is immediately
  dereferenced by the compiler

As suggested, remove the additional reference.
This commit is contained in:
Tobin C. Harding 2022-05-25 13:21:25 +10:00
parent 1940b00132
commit b7d6c3e02c
5 changed files with 13 additions and 13 deletions

View File

@ -469,9 +469,9 @@ impl Script {
/// the current script, assuming that the script is a Tapscript.
#[inline]
pub fn to_v1_p2tr<C: Verification>(&self, secp: &Secp256k1<C>, internal_key: UntweakedPublicKey) -> Script {
let leaf_hash = TapLeafHash::from_script(&self, LeafVersion::TapScript);
let leaf_hash = TapLeafHash::from_script(self, LeafVersion::TapScript);
let merkle_root = TapBranchHash::from_inner(leaf_hash.into_inner());
Script::new_v1_p2tr(&secp, internal_key, Some(merkle_root))
Script::new_v1_p2tr(secp, internal_key, Some(merkle_root))
}
/// Returns witness version of the script, if any, assuming the script is a `scriptPubkey`.

View File

@ -218,7 +218,7 @@ impl Witness {
pub fn push_bitcoin_signature(&mut self, signature: &ecdsa::SerializedSignature, hash_type: EcdsaSighashType) {
// Note that a maximal length ECDSA signature is 72 bytes, plus the sighash type makes 73
let mut sig = [0; 73];
sig[..signature.len()].copy_from_slice(&signature);
sig[..signature.len()].copy_from_slice(signature);
sig[signature.len()] = hash_type as u8;
self.push(&sig[..signature.len() + 1]);
}

View File

@ -125,7 +125,7 @@ impl Deserialize for EcdsaSig {
// also has a field sighash_u32 (See BIP141). For example, when signing with non-standard
// 0x05, the sighash message would have the last field as 0x05u32 while, the verification
// would use check the signature assuming sighash_u32 as `0x01`.
EcdsaSig::from_slice(&bytes)
EcdsaSig::from_slice(bytes)
.map_err(|e| match e {
EcdsaSigError::EmptySignature => {
encode::Error::ParseFailed("Empty partial signature data")
@ -145,7 +145,7 @@ impl Deserialize for EcdsaSig {
impl Serialize for KeySource {
fn serialize(&self) -> Vec<u8> {
let mut rv: Vec<u8> = Vec::with_capacity(key_source_len(&self));
let mut rv: Vec<u8> = Vec::with_capacity(key_source_len(self));
rv.append(&mut self.0.to_bytes().to_vec());
@ -207,7 +207,7 @@ impl Deserialize for PsbtSighashType {
// Taproot related ser/deser
impl Serialize for XOnlyPublicKey {
fn serialize(&self) -> Vec<u8> {
XOnlyPublicKey::serialize(&self).to_vec()
XOnlyPublicKey::serialize(self).to_vec()
}
}
@ -226,7 +226,7 @@ impl Serialize for schnorr::SchnorrSig {
impl Deserialize for schnorr::SchnorrSig {
fn deserialize(bytes: &[u8]) -> Result<Self, encode::Error> {
schnorr::SchnorrSig::from_slice(&bytes)
schnorr::SchnorrSig::from_slice(bytes)
.map_err(|e| match e {
schnorr::SchnorrSigError::InvalidSighashType(flag) => {
encode::Error::from(psbt::Error::NonStandardSighashType(flag as u32))
@ -264,7 +264,7 @@ impl Deserialize for (XOnlyPublicKey, TapLeafHash) {
impl Serialize for ControlBlock {
fn serialize(&self) -> Vec<u8> {
ControlBlock::serialize(&self)
ControlBlock::serialize(self)
}
}
@ -311,7 +311,7 @@ impl Serialize for (Vec<TapLeafHash>, KeySource) {
impl Deserialize for (Vec<TapLeafHash>, KeySource) {
fn deserialize(bytes: &[u8]) -> Result<Self, encode::Error> {
let (leafhash_vec, consumed) = deserialize_partial::<Vec<TapLeafHash>>(&bytes)?;
let (leafhash_vec, consumed) = deserialize_partial::<Vec<TapLeafHash>>(bytes)?;
let key_source = KeySource::deserialize(&bytes[consumed..])?;
Ok((leafhash_vec, key_source))
}

View File

@ -110,9 +110,9 @@ impl TapTweak for UntweakedPublicKey {
fn tap_tweak<C: Verification>(self, secp: &Secp256k1<C>, merkle_root: Option<TapBranchHash>) -> (TweakedPublicKey, secp256k1::Parity) {
let tweak_value = TapTweakHash::from_key_and_tweak(self, merkle_root).into_inner();
let mut output_key = self.clone();
let parity = output_key.tweak_add_assign(&secp, &tweak_value).expect("Tap tweak failed");
let parity = output_key.tweak_add_assign(secp, &tweak_value).expect("Tap tweak failed");
debug_assert!(self.tweak_add_check(&secp, &output_key, parity, tweak_value));
debug_assert!(self.tweak_add_check(secp, &output_key, parity, tweak_value));
(TweakedPublicKey(output_key), parity)
}
@ -140,7 +140,7 @@ impl TapTweak for UntweakedKeyPair {
fn tap_tweak<C: Verification>(mut self, secp: &Secp256k1<C>, merkle_root: Option<TapBranchHash>) -> TweakedKeyPair {
let pubkey = crate::XOnlyPublicKey::from_keypair(&self);
let tweak_value = TapTweakHash::from_key_and_tweak(pubkey, merkle_root).into_inner();
self.tweak_add_assign(&secp, &tweak_value).expect("Tap tweak failed");
self.tweak_add_assign(secp, &tweak_value).expect("Tap tweak failed");
TweakedKeyPair(self)
}

View File

@ -802,7 +802,7 @@ impl ControlBlock {
) -> bool {
// compute the script hash
// Initially the curr_hash is the leaf hash
let leaf_hash = TapLeafHash::from_script(&script, self.leaf_version);
let leaf_hash = TapLeafHash::from_script(script, self.leaf_version);
let mut curr_hash = TapBranchHash::from_inner(leaf_hash.into_inner());
// Verify the proof
for elem in self.merkle_branch.as_inner() {