@@ -1180,13 +1180,6 @@ impl HolderCommitmentTransaction {
11801180 let dummy_key = PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
11811181 let dummy_sig = sign ( & secp_ctx, & secp256k1:: Message :: from_digest ( [ 42 ; 32 ] ) , & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
11821182
1183- let keys = TxCreationKeys {
1184- per_commitment_point : dummy_key. clone ( ) ,
1185- revocation_key : RevocationKey :: from_basepoint ( & secp_ctx, & RevocationBasepoint :: from ( dummy_key) , & dummy_key) ,
1186- broadcaster_htlc_key : HtlcKey :: from_basepoint ( & secp_ctx, & HtlcBasepoint :: from ( dummy_key) , & dummy_key) ,
1187- countersignatory_htlc_key : HtlcKey :: from_basepoint ( & secp_ctx, & HtlcBasepoint :: from ( dummy_key) , & dummy_key) ,
1188- broadcaster_delayed_payment_key : DelayedPaymentKey :: from_basepoint ( & secp_ctx, & DelayedPaymentBasepoint :: from ( dummy_key) , & dummy_key) ,
1189- } ;
11901183 let channel_pubkeys = ChannelPublicKeys {
11911184 funding_pubkey : dummy_key. clone ( ) ,
11921185 revocation_basepoint : RevocationBasepoint :: from ( dummy_key) ,
@@ -1208,7 +1201,7 @@ impl HolderCommitmentTransaction {
12081201 for _ in 0 ..htlcs. len ( ) {
12091202 counterparty_htlc_sigs. push ( dummy_sig) ;
12101203 }
1211- let inner = CommitmentTransaction :: new_with_auxiliary_htlc_data ( 0 , 0 , 0 , keys , 0 , htlcs, & channel_parameters. as_counterparty_broadcastable ( ) ) ;
1204+ let inner = CommitmentTransaction :: new_with_auxiliary_htlc_data ( 0 , & dummy_key , 0 , 0 , 0 , htlcs, & channel_parameters. as_counterparty_broadcastable ( ) , & secp_ctx ) ;
12121205 htlcs. sort_by_key ( |htlc| htlc. 0 . transaction_output_index ) ;
12131206 HolderCommitmentTransaction {
12141207 inner,
@@ -1518,9 +1511,10 @@ impl CommitmentTransaction {
15181511 /// Only include HTLCs that are above the dust limit for the channel.
15191512 ///
15201513 /// This is not exported to bindings users due to the generic though we likely should expose a version without
1521- pub fn new_with_auxiliary_htlc_data < T > ( commitment_number : u64 , to_broadcaster_value_sat : u64 , to_countersignatory_value_sat : u64 , keys : TxCreationKeys , feerate_per_kw : u32 , htlcs_with_aux : & mut Vec < ( HTLCOutputInCommitment , T ) > , channel_parameters : & DirectedChannelTransactionParameters ) -> CommitmentTransaction {
1514+ pub fn new_with_auxiliary_htlc_data < T > ( commitment_number : u64 , per_commitment_point : & PublicKey , to_broadcaster_value_sat : u64 , to_countersignatory_value_sat : u64 , feerate_per_kw : u32 , htlcs_with_aux : & mut Vec < ( HTLCOutputInCommitment , T ) > , channel_parameters : & DirectedChannelTransactionParameters , secp_ctx : & Secp256k1 < secp256k1 :: All > ) -> CommitmentTransaction {
15221515 let to_broadcaster_value_sat = Amount :: from_sat ( to_broadcaster_value_sat) ;
15231516 let to_countersignatory_value_sat = Amount :: from_sat ( to_countersignatory_value_sat) ;
1517+ let keys = TxCreationKeys :: from_channel_static_keys ( per_commitment_point, channel_parameters. broadcaster_pubkeys ( ) , channel_parameters. countersignatory_pubkeys ( ) , secp_ctx) ;
15241518
15251519 // Sort outputs and populate output indices while keeping track of the auxiliary data
15261520 let ( outputs, htlcs) = Self :: internal_build_outputs ( & keys, to_broadcaster_value_sat, to_countersignatory_value_sat, htlcs_with_aux, channel_parameters) . unwrap ( ) ;
@@ -1970,8 +1964,8 @@ pub fn get_commitment_transaction_number_obscure_factor(
19701964mod tests {
19711965 use super :: { CounterpartyCommitmentSecrets , ChannelPublicKeys } ;
19721966 use crate :: chain;
1973- use crate :: ln:: chan_utils:: { get_htlc_redeemscript, get_to_countersigner_keyed_anchor_redeemscript, CommitmentTransaction , TxCreationKeys , ChannelTransactionParameters , CounterpartyChannelTransactionParameters , HTLCOutputInCommitment } ;
1974- use bitcoin:: secp256k1:: { PublicKey , SecretKey , Secp256k1 } ;
1967+ use crate :: ln:: chan_utils:: { get_htlc_redeemscript, get_to_countersigner_keyed_anchor_redeemscript, CommitmentTransaction , ChannelTransactionParameters , CounterpartyChannelTransactionParameters , HTLCOutputInCommitment } ;
1968+ use bitcoin:: secp256k1:: { self , PublicKey , SecretKey , Secp256k1 } ;
19751969 use crate :: util:: test_utils;
19761970 use crate :: sign:: { ChannelSigner , SignerProvider } ;
19771971 use bitcoin:: { Network , Txid , ScriptBuf , CompressedPublicKey } ;
@@ -1986,11 +1980,12 @@ mod tests {
19861980
19871981 struct TestCommitmentTxBuilder {
19881982 commitment_number : u64 ,
1989- keys : TxCreationKeys ,
1983+ per_commitment_point : PublicKey ,
19901984 feerate_per_kw : u32 ,
19911985 htlcs_with_aux : Vec < ( HTLCOutputInCommitment , ( ) ) > ,
19921986 channel_parameters : ChannelTransactionParameters ,
19931987 counterparty_pubkeys : ChannelPublicKeys ,
1988+ secp_ctx : Secp256k1 :: < secp256k1:: All > ,
19941989 }
19951990
19961991 impl TestCommitmentTxBuilder {
@@ -2015,28 +2010,23 @@ mod tests {
20152010 channel_type_features : ChannelTypeFeatures :: only_static_remote_key ( ) ,
20162011 channel_value_satoshis : 3000 ,
20172012 } ;
2018- let directed_parameters = channel_parameters. as_holder_broadcastable ( ) ;
2019- let keys = TxCreationKeys :: from_channel_static_keys (
2020- & per_commitment_point, directed_parameters. broadcaster_pubkeys ( ) ,
2021- directed_parameters. countersignatory_pubkeys ( ) , & secp_ctx,
2022- ) ;
20232013 let htlcs_with_aux = Vec :: new ( ) ;
20242014
20252015 Self {
20262016 commitment_number : 0 ,
2027- keys ,
2017+ per_commitment_point ,
20282018 feerate_per_kw : 1 ,
20292019 htlcs_with_aux,
20302020 channel_parameters,
20312021 counterparty_pubkeys,
2022+ secp_ctx,
20322023 }
20332024 }
20342025
20352026 fn build ( & mut self , to_broadcaster_sats : u64 , to_countersignatory_sats : u64 ) -> CommitmentTransaction {
20362027 CommitmentTransaction :: new_with_auxiliary_htlc_data (
2037- self . commitment_number , to_broadcaster_sats, to_countersignatory_sats,
2038- self . keys . clone ( ) , self . feerate_per_kw ,
2039- & mut self . htlcs_with_aux , & self . channel_parameters . as_holder_broadcastable ( )
2028+ self . commitment_number , & self . per_commitment_point , to_broadcaster_sats, to_countersignatory_sats, self . feerate_per_kw ,
2029+ & mut self . htlcs_with_aux , & self . channel_parameters . as_holder_broadcastable ( ) , & self . secp_ctx
20402030 )
20412031 }
20422032 }
@@ -2084,7 +2074,7 @@ mod tests {
20842074 builder. channel_parameters . channel_type_features = ChannelTypeFeatures :: only_static_remote_key ( ) ;
20852075 builder. htlcs_with_aux = vec ! [ ( received_htlc. clone( ) , ( ) ) , ( offered_htlc. clone( ) , ( ) ) ] ;
20862076 let tx = builder. build ( 3000 , 0 ) ;
2087- let keys = & builder . keys . clone ( ) ;
2077+ let keys = tx . trust ( ) . keys ( ) ;
20882078 assert_eq ! ( tx. built. transaction. output. len( ) , 3 ) ;
20892079 assert_eq ! ( tx. built. transaction. output[ 0 ] . script_pubkey, get_htlc_redeemscript( & received_htlc, & ChannelTypeFeatures :: only_static_remote_key( ) , & keys) . to_p2wsh( ) ) ;
20902080 assert_eq ! ( tx. built. transaction. output[ 1 ] . script_pubkey, get_htlc_redeemscript( & offered_htlc, & ChannelTypeFeatures :: only_static_remote_key( ) , & keys) . to_p2wsh( ) ) ;
0 commit comments