@@ -1171,13 +1171,6 @@ impl HolderCommitmentTransaction {
11711171 let dummy_key = PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
11721172 let dummy_sig = sign ( & secp_ctx, & secp256k1:: Message :: from_digest ( [ 42 ; 32 ] ) , & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
11731173
1174- let keys = TxCreationKeys {
1175- per_commitment_point : dummy_key. clone ( ) ,
1176- revocation_key : RevocationKey :: from_basepoint ( & secp_ctx, & RevocationBasepoint :: from ( dummy_key) , & dummy_key) ,
1177- broadcaster_htlc_key : HtlcKey :: from_basepoint ( & secp_ctx, & HtlcBasepoint :: from ( dummy_key) , & dummy_key) ,
1178- countersignatory_htlc_key : HtlcKey :: from_basepoint ( & secp_ctx, & HtlcBasepoint :: from ( dummy_key) , & dummy_key) ,
1179- broadcaster_delayed_payment_key : DelayedPaymentKey :: from_basepoint ( & secp_ctx, & DelayedPaymentBasepoint :: from ( dummy_key) , & dummy_key) ,
1180- } ;
11811174 let channel_pubkeys = ChannelPublicKeys {
11821175 funding_pubkey : dummy_key. clone ( ) ,
11831176 revocation_basepoint : RevocationBasepoint :: from ( dummy_key) ,
@@ -1199,7 +1192,7 @@ impl HolderCommitmentTransaction {
11991192 for _ in 0 ..htlcs. len ( ) {
12001193 counterparty_htlc_sigs. push ( dummy_sig) ;
12011194 }
1202- let inner = CommitmentTransaction :: new_with_auxiliary_htlc_data ( 0 , 0 , 0 , keys , 0 , htlcs, & channel_parameters. as_counterparty_broadcastable ( ) ) ;
1195+ let inner = CommitmentTransaction :: new_with_auxiliary_htlc_data ( 0 , & dummy_key , 0 , 0 , 0 , htlcs, & channel_parameters. as_counterparty_broadcastable ( ) , & secp_ctx ) ;
12031196 htlcs. sort_by_key ( |htlc| htlc. 0 . transaction_output_index ) ;
12041197 HolderCommitmentTransaction {
12051198 inner,
@@ -1509,9 +1502,10 @@ impl CommitmentTransaction {
15091502 /// Only include HTLCs that are above the dust limit for the channel.
15101503 ///
15111504 /// This is not exported to bindings users due to the generic though we likely should expose a version without
1512- 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 {
1505+ 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 {
15131506 let to_broadcaster_value_sat = Amount :: from_sat ( to_broadcaster_value_sat) ;
15141507 let to_countersignatory_value_sat = Amount :: from_sat ( to_countersignatory_value_sat) ;
1508+ let keys = TxCreationKeys :: from_channel_static_keys ( per_commitment_point, channel_parameters. broadcaster_pubkeys ( ) , channel_parameters. countersignatory_pubkeys ( ) , secp_ctx) ;
15151509
15161510 // Sort outputs and populate output indices while keeping track of the auxiliary data
15171511 let ( outputs, htlcs) = Self :: internal_build_outputs ( & keys, to_broadcaster_value_sat, to_countersignatory_value_sat, htlcs_with_aux, channel_parameters) . unwrap ( ) ;
@@ -1961,8 +1955,8 @@ pub fn get_commitment_transaction_number_obscure_factor(
19611955mod tests {
19621956 use super :: { CounterpartyCommitmentSecrets , ChannelPublicKeys } ;
19631957 use crate :: chain;
1964- use crate :: ln:: chan_utils:: { get_htlc_redeemscript, get_to_countersignatory_with_anchors_redeemscript, CommitmentTransaction , TxCreationKeys , ChannelTransactionParameters , CounterpartyChannelTransactionParameters , HTLCOutputInCommitment } ;
1965- use bitcoin:: secp256k1:: { PublicKey , SecretKey , Secp256k1 } ;
1958+ use crate :: ln:: chan_utils:: { get_htlc_redeemscript, get_to_countersignatory_with_anchors_redeemscript, CommitmentTransaction , ChannelTransactionParameters , CounterpartyChannelTransactionParameters , HTLCOutputInCommitment } ;
1959+ use bitcoin:: secp256k1:: { self , PublicKey , SecretKey , Secp256k1 } ;
19661960 use crate :: util:: test_utils;
19671961 use crate :: sign:: { ChannelSigner , SignerProvider } ;
19681962 use bitcoin:: { Network , Txid , ScriptBuf , CompressedPublicKey } ;
@@ -1977,11 +1971,12 @@ mod tests {
19771971
19781972 struct TestCommitmentTxBuilder {
19791973 commitment_number : u64 ,
1980- keys : TxCreationKeys ,
1974+ per_commitment_point : PublicKey ,
19811975 feerate_per_kw : u32 ,
19821976 htlcs_with_aux : Vec < ( HTLCOutputInCommitment , ( ) ) > ,
19831977 channel_parameters : ChannelTransactionParameters ,
19841978 counterparty_pubkeys : ChannelPublicKeys ,
1979+ secp_ctx : Secp256k1 :: < secp256k1:: All > ,
19851980 }
19861981
19871982 impl TestCommitmentTxBuilder {
@@ -2006,28 +2001,23 @@ mod tests {
20062001 channel_type_features : ChannelTypeFeatures :: only_static_remote_key ( ) ,
20072002 channel_value_satoshis : 3000 ,
20082003 } ;
2009- let directed_parameters = channel_parameters. as_holder_broadcastable ( ) ;
2010- let keys = TxCreationKeys :: from_channel_static_keys (
2011- & per_commitment_point, directed_parameters. broadcaster_pubkeys ( ) ,
2012- directed_parameters. countersignatory_pubkeys ( ) , & secp_ctx,
2013- ) ;
20142004 let htlcs_with_aux = Vec :: new ( ) ;
20152005
20162006 Self {
20172007 commitment_number : 0 ,
2018- keys ,
2008+ per_commitment_point ,
20192009 feerate_per_kw : 1 ,
20202010 htlcs_with_aux,
20212011 channel_parameters,
20222012 counterparty_pubkeys,
2013+ secp_ctx,
20232014 }
20242015 }
20252016
20262017 fn build ( & mut self , to_broadcaster_sats : u64 , to_countersignatory_sats : u64 ) -> CommitmentTransaction {
20272018 CommitmentTransaction :: new_with_auxiliary_htlc_data (
2028- self . commitment_number , to_broadcaster_sats, to_countersignatory_sats,
2029- self . keys . clone ( ) , self . feerate_per_kw ,
2030- & mut self . htlcs_with_aux , & self . channel_parameters . as_holder_broadcastable ( )
2019+ self . commitment_number , & self . per_commitment_point , to_broadcaster_sats, to_countersignatory_sats, self . feerate_per_kw ,
2020+ & mut self . htlcs_with_aux , & self . channel_parameters . as_holder_broadcastable ( ) , & self . secp_ctx
20312021 )
20322022 }
20332023 }
@@ -2075,7 +2065,7 @@ mod tests {
20752065 builder. channel_parameters . channel_type_features = ChannelTypeFeatures :: only_static_remote_key ( ) ;
20762066 builder. htlcs_with_aux = vec ! [ ( received_htlc. clone( ) , ( ) ) , ( offered_htlc. clone( ) , ( ) ) ] ;
20772067 let tx = builder. build ( 3000 , 0 ) ;
2078- let keys = & builder . keys . clone ( ) ;
2068+ let keys = tx . trust ( ) . keys ( ) ;
20792069 assert_eq ! ( tx. built. transaction. output. len( ) , 3 ) ;
20802070 assert_eq ! ( tx. built. transaction. output[ 0 ] . script_pubkey, get_htlc_redeemscript( & received_htlc, & ChannelTypeFeatures :: only_static_remote_key( ) , & keys) . to_p2wsh( ) ) ;
20812071 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