Skip to content

Commit

Permalink
Remove additional reference
Browse files Browse the repository at this point in the history
Clippy emits:

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

As suggested, remove the additional reference.
  • Loading branch information
tcharding committed May 25, 2022
1 parent 1940b00 commit b7d6c3e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/blockdata/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
2 changes: 1 addition & 1 deletion src/blockdata/witness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
Expand Down
12 changes: 6 additions & 6 deletions src/util/psbt/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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());

Expand Down Expand Up @@ -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()
}
}

Expand All @@ -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))
Expand Down Expand Up @@ -264,7 +264,7 @@ impl Deserialize for (XOnlyPublicKey, TapLeafHash) {

impl Serialize for ControlBlock {
fn serialize(&self) -> Vec<u8> {
ControlBlock::serialize(&self)
ControlBlock::serialize(self)
}
}

Expand Down Expand Up @@ -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))
}
Expand Down
6 changes: 3 additions & 3 deletions src/util/schnorr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/taproot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit b7d6c3e

Please sign in to comment.