Code style fixups to taproot key functions
This commit is contained in:
parent
7514f2ca18
commit
6364ebd927
|
@ -344,9 +344,6 @@ impl Script {
|
|||
}
|
||||
|
||||
/// Generates P2TR for key spending path for a known [`TweakedPublicKey`].
|
||||
///
|
||||
/// NB: Make sure that the used key is indeed tweaked (for instance, it comes from `rawtr`
|
||||
/// descriptor content); otherwise please use [`Script::new_v1_p2tr`] method.
|
||||
pub fn new_v1_p2tr_tweaked(output_key: TweakedPublicKey) -> Script {
|
||||
Script::new_witness_program(WitnessVersion::V1, &output_key.serialize())
|
||||
}
|
||||
|
@ -414,7 +411,7 @@ impl Script {
|
|||
|
||||
#[inline]
|
||||
fn witness_version(&self) -> Option<WitnessVersion> {
|
||||
WitnessVersion::from_opcode(self.0[0].into()).ok()
|
||||
self.0.get(0).and_then(|opcode| WitnessVersion::from_opcode(opcodes::All::from(*opcode)).ok())
|
||||
}
|
||||
|
||||
/// Checks whether a script pubkey is a p2sh output
|
||||
|
|
|
@ -128,12 +128,11 @@ impl TapTweak for UntweakedKeyPair {
|
|||
///
|
||||
/// # Returns
|
||||
/// The tweaked key and its parity.
|
||||
fn tap_tweak<C: Verification>(self, secp: &Secp256k1<C>, merkle_root: Option<TapBranchHash>) -> TweakedKeyPair {
|
||||
fn tap_tweak<C: Verification>(mut self, secp: &Secp256k1<C>, merkle_root: Option<TapBranchHash>) -> TweakedKeyPair {
|
||||
let pubkey = XOnlyPublicKey::from_keypair(&self);
|
||||
let tweak_value = TapTweakHash::from_key_and_tweak(pubkey, merkle_root).into_inner();
|
||||
let mut output_key = self.clone();
|
||||
output_key.tweak_add_assign(&secp, &tweak_value).expect("Tap tweak failed");
|
||||
TweakedKeyPair(output_key)
|
||||
self.tweak_add_assign(&secp, &tweak_value).expect("Tap tweak failed");
|
||||
TweakedKeyPair(self)
|
||||
}
|
||||
|
||||
fn dangerous_assume_tweaked(self) -> TweakedKeyPair {
|
||||
|
|
Loading…
Reference in New Issue