Merge rust-bitcoin/rust-bitcoin#3058: Improve `define_extension_trait`
386ad93253
Manually format function parameters (Tobin C. Harding)871f4398b9
Add optional comma to function parameter list (Tobin C. Harding) Pull request description: During #2955 I was lazy and did not think through why the macro didn't handle function parameters on individual lines, I just manually re-formatted all function calls onto a single LOC. This was a bit slack of me. - Patch 1: Fix the macro. - Patch 2: Revert the manual formatting. ACKs for top commit: jamillambert: ACK386ad93253
Kixunil: ACK386ad93253
apoelstra: ACK386ad93253
Tree-SHA512: 577154668a4cd0bad225a5b306193a5cd3d38d275dd5df22b4a29737e0d2c910c695da33c0ed77265f6c5d876c162316e444f8eca80f9c30788d110d989493e3
This commit is contained in:
commit
128684e0da
|
@ -48,7 +48,11 @@ define_extension_trait! {
|
||||||
|
|
||||||
/// Computes P2TR output with a given internal key and a single script spending path equal to
|
/// Computes P2TR output with a given internal key and a single script spending path equal to
|
||||||
/// the current script, assuming that the script is a Tapscript.
|
/// the current script, assuming that the script is a Tapscript.
|
||||||
fn to_p2tr<C: Verification>(&self, secp: &Secp256k1<C>, internal_key: UntweakedPublicKey) -> ScriptBuf {
|
fn to_p2tr<C: Verification>(
|
||||||
|
&self,
|
||||||
|
secp: &Secp256k1<C>,
|
||||||
|
internal_key: UntweakedPublicKey,
|
||||||
|
) -> ScriptBuf {
|
||||||
let leaf_hash = self.tapscript_leaf_hash();
|
let leaf_hash = self.tapscript_leaf_hash();
|
||||||
let merkle_root = TapNodeHash::from(leaf_hash);
|
let merkle_root = TapNodeHash::from(leaf_hash);
|
||||||
ScriptBuf::new_p2tr(secp, internal_key, Some(merkle_root))
|
ScriptBuf::new_p2tr(secp, internal_key, Some(merkle_root))
|
||||||
|
@ -150,7 +154,11 @@ define_extension_trait! {
|
||||||
|
|
||||||
/// Generates P2TR for script spending path using an internal public key and some optional
|
/// Generates P2TR for script spending path using an internal public key and some optional
|
||||||
/// script tree Merkle root.
|
/// script tree Merkle root.
|
||||||
fn new_p2tr<C: Verification>(secp: &Secp256k1<C>, internal_key: UntweakedPublicKey, merkle_root: Option<TapNodeHash>) -> Self {
|
fn new_p2tr<C: Verification>(
|
||||||
|
secp: &Secp256k1<C>,
|
||||||
|
internal_key: UntweakedPublicKey,
|
||||||
|
merkle_root: Option<TapNodeHash>,
|
||||||
|
) -> Self {
|
||||||
let (output_key, _) = internal_key.tap_tweak(secp, merkle_root);
|
let (output_key, _) = internal_key.tap_tweak(secp, merkle_root);
|
||||||
// output key is 32 bytes long, so it's safe to use `new_witness_program_unchecked` (Segwitv1)
|
// output key is 32 bytes long, so it's safe to use `new_witness_program_unchecked` (Segwitv1)
|
||||||
new_witness_program_unchecked(WitnessVersion::V1, output_key.serialize())
|
new_witness_program_unchecked(WitnessVersion::V1, output_key.serialize())
|
||||||
|
|
|
@ -218,7 +218,7 @@ macro_rules! define_extension_trait {
|
||||||
($(#[$($trait_attrs:tt)*])* $trait_vis:vis trait $trait_name:ident impl for $ty:ident {
|
($(#[$($trait_attrs:tt)*])* $trait_vis:vis trait $trait_name:ident impl for $ty:ident {
|
||||||
$(
|
$(
|
||||||
$(#[$($fn_attrs:tt)*])*
|
$(#[$($fn_attrs:tt)*])*
|
||||||
fn $fn:ident($slf:ident $(, $param_name:ident: $param_type:ty)*) $( -> $ret:ty )? $body:block
|
fn $fn:ident($slf:ident $(, $param_name:ident: $param_type:ty)* $(,)?) $( -> $ret:ty )? $body:block
|
||||||
)*
|
)*
|
||||||
}) => {
|
}) => {
|
||||||
$(#[$($trait_attrs)*])* $trait_vis trait $trait_name {
|
$(#[$($trait_attrs)*])* $trait_vis trait $trait_name {
|
||||||
|
@ -238,7 +238,7 @@ macro_rules! define_extension_trait {
|
||||||
($(#[$($trait_attrs:tt)*])* $trait_vis:vis trait $trait_name:ident impl for $ty:ident {
|
($(#[$($trait_attrs:tt)*])* $trait_vis:vis trait $trait_name:ident impl for $ty:ident {
|
||||||
$(
|
$(
|
||||||
$(#[$($fn_attrs:tt)*])*
|
$(#[$($fn_attrs:tt)*])*
|
||||||
fn $fn:ident(&$slf:ident $(, $param_name:ident: $param_type:ty)*) $( -> $ret:ty )? $body:block
|
fn $fn:ident(&$slf:ident $(, $param_name:ident: $param_type:ty)* $(,)?) $( -> $ret:ty )? $body:block
|
||||||
)*
|
)*
|
||||||
}) => {
|
}) => {
|
||||||
$(#[$($trait_attrs)*])* $trait_vis trait $trait_name {
|
$(#[$($trait_attrs)*])* $trait_vis trait $trait_name {
|
||||||
|
@ -258,7 +258,7 @@ macro_rules! define_extension_trait {
|
||||||
($(#[$($trait_attrs:tt)*])* $trait_vis:vis trait $trait_name:ident impl for $ty:ident {
|
($(#[$($trait_attrs:tt)*])* $trait_vis:vis trait $trait_name:ident impl for $ty:ident {
|
||||||
$(
|
$(
|
||||||
$(#[$($fn_attrs:tt)*])*
|
$(#[$($fn_attrs:tt)*])*
|
||||||
fn $fn:ident$(<$($gen:ident: $gent:ident),*>)?(&$slf:ident $(, $param_name:ident: $param_type:ty)*) $( -> $ret:ty )? $body:block
|
fn $fn:ident$(<$($gen:ident: $gent:ident),*>)?(&$slf:ident $(, $param_name:ident: $param_type:ty)* $(,)?) $( -> $ret:ty )? $body:block
|
||||||
)*
|
)*
|
||||||
}) => {
|
}) => {
|
||||||
$(#[$($trait_attrs)*])* $trait_vis trait $trait_name {
|
$(#[$($trait_attrs)*])* $trait_vis trait $trait_name {
|
||||||
|
@ -278,7 +278,7 @@ macro_rules! define_extension_trait {
|
||||||
($(#[$($trait_attrs:tt)*])* $trait_vis:vis trait $trait_name:ident impl for $ty:ident {
|
($(#[$($trait_attrs:tt)*])* $trait_vis:vis trait $trait_name:ident impl for $ty:ident {
|
||||||
$(
|
$(
|
||||||
$(#[$($fn_attrs:tt)*])*
|
$(#[$($fn_attrs:tt)*])*
|
||||||
fn $fn:ident$(<$($gen:ident: $gent:ident),*>)?($($param_name:ident: $param_type:ty),*) $( -> $ret:ty )? $body:block
|
fn $fn:ident$(<$($gen:ident: $gent:ident),*>)?($($param_name:ident: $param_type:ty),* $(,)?) $( -> $ret:ty )? $body:block
|
||||||
)*
|
)*
|
||||||
}) => {
|
}) => {
|
||||||
$(#[$($trait_attrs)*])* $trait_vis trait $trait_name {
|
$(#[$($trait_attrs)*])* $trait_vis trait $trait_name {
|
||||||
|
@ -298,7 +298,7 @@ macro_rules! define_extension_trait {
|
||||||
($(#[$($trait_attrs:tt)*])* $trait_vis:vis trait $trait_name:ident impl for $ty:ident {
|
($(#[$($trait_attrs:tt)*])* $trait_vis:vis trait $trait_name:ident impl for $ty:ident {
|
||||||
$(
|
$(
|
||||||
$(#[$($fn_attrs:tt)*])*
|
$(#[$($fn_attrs:tt)*])*
|
||||||
fn $fn:ident<T: AsRef<PushBytes>>($($param_name:ident: $param_type:ty),*) $( -> $ret:ty )? $body:block
|
fn $fn:ident<T: AsRef<PushBytes>>($($param_name:ident: $param_type:ty),* $(,)?) $( -> $ret:ty )? $body:block
|
||||||
)*
|
)*
|
||||||
}) => {
|
}) => {
|
||||||
$(#[$($trait_attrs)*])* $trait_vis trait $trait_name {
|
$(#[$($trait_attrs)*])* $trait_vis trait $trait_name {
|
||||||
|
|
Loading…
Reference in New Issue