@@ -1150,13 +1150,6 @@ impl HolderCommitmentTransaction {
11501150 let dummy_key = PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
11511151 let dummy_sig = sign ( & secp_ctx, & secp256k1:: Message :: from_digest ( [ 42 ; 32 ] ) , & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
11521152
1153- let keys = TxCreationKeys {
1154- per_commitment_point : dummy_key. clone ( ) ,
1155- revocation_key : RevocationKey :: from_basepoint ( & secp_ctx, & RevocationBasepoint :: from ( dummy_key) , & dummy_key) ,
1156- broadcaster_htlc_key : HtlcKey :: from_basepoint ( & secp_ctx, & HtlcBasepoint :: from ( dummy_key) , & dummy_key) ,
1157- countersignatory_htlc_key : HtlcKey :: from_basepoint ( & secp_ctx, & HtlcBasepoint :: from ( dummy_key) , & dummy_key) ,
1158- broadcaster_delayed_payment_key : DelayedPaymentKey :: from_basepoint ( & secp_ctx, & DelayedPaymentBasepoint :: from ( dummy_key) , & dummy_key) ,
1159- } ;
11601153 let channel_pubkeys = ChannelPublicKeys {
11611154 funding_pubkey : dummy_key. clone ( ) ,
11621155 revocation_basepoint : RevocationBasepoint :: from ( dummy_key) ,
@@ -1178,7 +1171,7 @@ impl HolderCommitmentTransaction {
11781171 for _ in 0 ..htlcs. len ( ) {
11791172 counterparty_htlc_sigs. push ( dummy_sig) ;
11801173 }
1181- let inner = CommitmentTransaction :: new_with_auxiliary_htlc_data ( 0 , 0 , 0 , keys , 0 , htlcs, & channel_parameters. as_counterparty_broadcastable ( ) ) ;
1174+ let inner = CommitmentTransaction :: new_with_auxiliary_htlc_data ( 0 , & dummy_key . clone ( ) , 0 , 0 , 0 , htlcs, & channel_parameters. as_counterparty_broadcastable ( ) , & secp_ctx ) ;
11821175 htlcs. sort_by_key ( |htlc| htlc. 0 . transaction_output_index ) ;
11831176 HolderCommitmentTransaction {
11841177 inner,
@@ -1488,9 +1481,10 @@ impl CommitmentTransaction {
14881481 /// Only include HTLCs that are above the dust limit for the channel.
14891482 ///
14901483 /// This is not exported to bindings users due to the generic though we likely should expose a version without
1491- 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 {
1484+ 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 {
14921485 let to_broadcaster_value_sat = Amount :: from_sat ( to_broadcaster_value_sat) ;
14931486 let to_countersignatory_value_sat = Amount :: from_sat ( to_countersignatory_value_sat) ;
1487+ let keys = TxCreationKeys :: from_channel_static_keys ( per_commitment_point, channel_parameters. broadcaster_pubkeys ( ) , channel_parameters. countersignatory_pubkeys ( ) , secp_ctx) ;
14941488
14951489 // Sort outputs and populate output indices while keeping track of the auxiliary data
14961490 let ( outputs, htlcs) = Self :: internal_build_outputs ( & keys, to_broadcaster_value_sat, to_countersignatory_value_sat, htlcs_with_aux, channel_parameters) . unwrap ( ) ;
@@ -1939,8 +1933,8 @@ pub fn get_commitment_transaction_number_obscure_factor(
19391933mod tests {
19401934 use super :: { CounterpartyCommitmentSecrets , ChannelPublicKeys } ;
19411935 use crate :: chain;
1942- use crate :: ln:: chan_utils:: { get_htlc_redeemscript, get_to_countersignatory_with_anchors_redeemscript, CommitmentTransaction , TxCreationKeys , ChannelTransactionParameters , CounterpartyChannelTransactionParameters , HTLCOutputInCommitment } ;
1943- use bitcoin:: secp256k1:: { PublicKey , SecretKey , Secp256k1 } ;
1936+ use crate :: ln:: chan_utils:: { get_htlc_redeemscript, get_to_countersignatory_with_anchors_redeemscript, CommitmentTransaction , ChannelTransactionParameters , CounterpartyChannelTransactionParameters , HTLCOutputInCommitment } ;
1937+ use bitcoin:: secp256k1:: { self , PublicKey , SecretKey , Secp256k1 } ;
19441938 use crate :: util:: test_utils;
19451939 use crate :: sign:: { ChannelSigner , SignerProvider } ;
19461940 use bitcoin:: { Network , Txid , ScriptBuf , CompressedPublicKey } ;
@@ -1955,11 +1949,12 @@ mod tests {
19551949
19561950 struct TestCommitmentTxBuilder {
19571951 commitment_number : u64 ,
1958- keys : TxCreationKeys ,
1952+ per_commitment_point : PublicKey ,
19591953 feerate_per_kw : u32 ,
19601954 htlcs_with_aux : Vec < ( HTLCOutputInCommitment , ( ) ) > ,
19611955 channel_parameters : ChannelTransactionParameters ,
19621956 counterparty_pubkeys : ChannelPublicKeys ,
1957+ secp_ctx : Secp256k1 :: < secp256k1:: All > ,
19631958 }
19641959
19651960 impl TestCommitmentTxBuilder {
@@ -1984,28 +1979,23 @@ mod tests {
19841979 channel_type_features : ChannelTypeFeatures :: only_static_remote_key ( ) ,
19851980 channel_value_satoshis : 3000 ,
19861981 } ;
1987- let directed_parameters = channel_parameters. as_holder_broadcastable ( ) ;
1988- let keys = TxCreationKeys :: from_channel_static_keys (
1989- & per_commitment_point, directed_parameters. broadcaster_pubkeys ( ) ,
1990- directed_parameters. countersignatory_pubkeys ( ) , & secp_ctx,
1991- ) ;
19921982 let htlcs_with_aux = Vec :: new ( ) ;
19931983
19941984 Self {
19951985 commitment_number : 0 ,
1996- keys ,
1986+ per_commitment_point ,
19971987 feerate_per_kw : 1 ,
19981988 htlcs_with_aux,
19991989 channel_parameters,
20001990 counterparty_pubkeys,
1991+ secp_ctx,
20011992 }
20021993 }
20031994
20041995 fn build ( & mut self , to_broadcaster_sats : u64 , to_countersignatory_sats : u64 ) -> CommitmentTransaction {
20051996 CommitmentTransaction :: new_with_auxiliary_htlc_data (
2006- self . commitment_number , to_broadcaster_sats, to_countersignatory_sats,
2007- self . keys . clone ( ) , self . feerate_per_kw ,
2008- & mut self . htlcs_with_aux , & self . channel_parameters . as_holder_broadcastable ( )
1997+ self . commitment_number , & self . per_commitment_point , to_broadcaster_sats, to_countersignatory_sats, self . feerate_per_kw ,
1998+ & mut self . htlcs_with_aux , & self . channel_parameters . as_holder_broadcastable ( ) , & self . secp_ctx
20091999 )
20102000 }
20112001 }
@@ -2053,7 +2043,7 @@ mod tests {
20532043 builder. channel_parameters . channel_type_features = ChannelTypeFeatures :: only_static_remote_key ( ) ;
20542044 builder. htlcs_with_aux = vec ! [ ( received_htlc. clone( ) , ( ) ) , ( offered_htlc. clone( ) , ( ) ) ] ;
20552045 let tx = builder. build ( 3000 , 0 ) ;
2056- let keys = & builder . keys . clone ( ) ;
2046+ let keys = & tx . trust ( ) . keys ( ) ;
20572047 assert_eq ! ( tx. built. transaction. output. len( ) , 3 ) ;
20582048 assert_eq ! ( tx. built. transaction. output[ 0 ] . script_pubkey, get_htlc_redeemscript( & received_htlc, & ChannelTypeFeatures :: only_static_remote_key( ) , & keys) . to_p2wsh( ) ) ;
20592049 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