From 8f36c3979c736a82758252cad09a939563771dd6 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Tue, 29 Mar 2022 09:50:43 +1100 Subject: [PATCH] Use sighash not sig_hash in identifiers Recently we update all types and docs to use `Sighash` instead of `SigHash` because 'sighash' is a single word. We should apply the same logic to functions and variable names. Do not use an underscore in the identifier 'sighash'. --- src/util/psbt/serialize.rs | 2 +- src/util/sighash.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/util/psbt/serialize.rs b/src/util/psbt/serialize.rs index 2cae7096..b21c5109 100644 --- a/src/util/psbt/serialize.rs +++ b/src/util/psbt/serialize.rs @@ -373,7 +373,7 @@ mod tests { use super::*; #[test] - fn can_deserialize_non_standard_psbt_sig_hash_type() { + fn can_deserialize_non_standard_psbt_sighash_type() { let non_standard_sighash = [222u8, 0u8, 0u8, 0u8]; // 32 byte value. let sighash = PsbtSighashType::deserialize(&non_standard_sighash); assert!(sighash.is_ok()) diff --git a/src/util/sighash.rs b/src/util/sighash.rs index 983aae9c..228922ce 100644 --- a/src/util/sighash.rs +++ b/src/util/sighash.rs @@ -1039,9 +1039,9 @@ mod tests { Prevouts::All(&prevouts) }; - let mut sig_hash_cache = SighashCache::new(&tx); + let mut sighash_cache = SighashCache::new(&tx); - let hash = sig_hash_cache + let hash = sighash_cache .taproot_signature_hash(input_index, &prevouts, annex, leaf_hash, sighash_type) .unwrap(); let expected = Vec::from_hex(expected_hash).unwrap(); @@ -1093,7 +1093,7 @@ mod tests { let expected_tweak = hex_hash!(TapTweakHash, inp["intermediary"]["tweak"].as_str().unwrap()); let expected_tweaked_priv_key = hex_hash!(SecretKey, inp["intermediary"]["tweakedPrivkey"].as_str().unwrap()); let expected_sig_msg = Vec::::from_hex(inp["intermediary"]["sigMsg"].as_str().unwrap()).unwrap(); - let expected_sig_hash = hex_hash!(TapSighashHash, inp["intermediary"]["sigHash"].as_str().unwrap()); + let expected_sighash = hex_hash!(TapSighashHash, inp["intermediary"]["sigHash"].as_str().unwrap()); let sig_str = inp["expected"]["witness"][0].as_str().unwrap(); let (expected_key_spend_sig, expected_hash_ty) = if sig_str.len() == 128 { (secp256k1::schnorr::Signature::from_str(sig_str).unwrap(), SchnorrSighashType::Default) @@ -1117,7 +1117,7 @@ mod tests { None, hash_ty ).unwrap(); - let sig_hash = cache.taproot_signature_hash( + let sighash = cache.taproot_signature_hash( tx_ind, &Prevouts::All(&utxos), None, @@ -1125,13 +1125,13 @@ mod tests { hash_ty ).unwrap(); - let msg = secp256k1::Message::from_slice(&sig_hash).unwrap(); + let msg = secp256k1::Message::from_slice(&sighash).unwrap(); let key_spend_sig = secp.sign_schnorr_with_aux_rand(&msg, &tweaked_keypair, &[0u8; 32]); assert_eq!(expected_internal_pk, internal_key); assert_eq!(expected_tweak, tweak); assert_eq!(expected_sig_msg, sig_msg); - assert_eq!(expected_sig_hash, sig_hash); + assert_eq!(expected_sighash, sighash); assert_eq!(expected_hash_ty, hash_ty); assert_eq!(expected_key_spend_sig, key_spend_sig);