@@ -1180,13 +1180,6 @@ impl HolderCommitmentTransaction {
1180
1180
let dummy_key = PublicKey :: from_secret_key ( & secp_ctx, & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
1181
1181
let dummy_sig = sign ( & secp_ctx, & secp256k1:: Message :: from_digest ( [ 42 ; 32 ] ) , & SecretKey :: from_slice ( & [ 42 ; 32 ] ) . unwrap ( ) ) ;
1182
1182
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
- } ;
1190
1183
let channel_pubkeys = ChannelPublicKeys {
1191
1184
funding_pubkey : dummy_key. clone ( ) ,
1192
1185
revocation_basepoint : RevocationBasepoint :: from ( dummy_key) ,
@@ -1208,7 +1201,7 @@ impl HolderCommitmentTransaction {
1208
1201
for _ in 0 ..htlcs. len ( ) {
1209
1202
counterparty_htlc_sigs. push ( dummy_sig) ;
1210
1203
}
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 ) ;
1212
1205
htlcs. sort_by_key ( |htlc| htlc. 0 . transaction_output_index ) ;
1213
1206
HolderCommitmentTransaction {
1214
1207
inner,
@@ -1518,9 +1511,10 @@ impl CommitmentTransaction {
1518
1511
/// Only include HTLCs that are above the dust limit for the channel.
1519
1512
///
1520
1513
/// 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 {
1522
1515
let to_broadcaster_value_sat = Amount :: from_sat ( to_broadcaster_value_sat) ;
1523
1516
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) ;
1524
1518
1525
1519
// Sort outputs and populate output indices while keeping track of the auxiliary data
1526
1520
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(
1970
1964
mod tests {
1971
1965
use super :: { CounterpartyCommitmentSecrets , ChannelPublicKeys } ;
1972
1966
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 } ;
1975
1969
use crate :: util:: test_utils;
1976
1970
use crate :: sign:: { ChannelSigner , SignerProvider } ;
1977
1971
use bitcoin:: { Network , Txid , ScriptBuf , CompressedPublicKey } ;
@@ -1986,11 +1980,12 @@ mod tests {
1986
1980
1987
1981
struct TestCommitmentTxBuilder {
1988
1982
commitment_number : u64 ,
1989
- keys : TxCreationKeys ,
1983
+ per_commitment_point : PublicKey ,
1990
1984
feerate_per_kw : u32 ,
1991
1985
htlcs_with_aux : Vec < ( HTLCOutputInCommitment , ( ) ) > ,
1992
1986
channel_parameters : ChannelTransactionParameters ,
1993
1987
counterparty_pubkeys : ChannelPublicKeys ,
1988
+ secp_ctx : Secp256k1 :: < secp256k1:: All > ,
1994
1989
}
1995
1990
1996
1991
impl TestCommitmentTxBuilder {
@@ -2015,28 +2010,23 @@ mod tests {
2015
2010
channel_type_features : ChannelTypeFeatures :: only_static_remote_key ( ) ,
2016
2011
channel_value_satoshis : 3000 ,
2017
2012
} ;
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
- ) ;
2023
2013
let htlcs_with_aux = Vec :: new ( ) ;
2024
2014
2025
2015
Self {
2026
2016
commitment_number : 0 ,
2027
- keys ,
2017
+ per_commitment_point ,
2028
2018
feerate_per_kw : 1 ,
2029
2019
htlcs_with_aux,
2030
2020
channel_parameters,
2031
2021
counterparty_pubkeys,
2022
+ secp_ctx,
2032
2023
}
2033
2024
}
2034
2025
2035
2026
fn build ( & mut self , to_broadcaster_sats : u64 , to_countersignatory_sats : u64 ) -> CommitmentTransaction {
2036
2027
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
2040
2030
)
2041
2031
}
2042
2032
}
@@ -2084,7 +2074,7 @@ mod tests {
2084
2074
builder. channel_parameters . channel_type_features = ChannelTypeFeatures :: only_static_remote_key ( ) ;
2085
2075
builder. htlcs_with_aux = vec ! [ ( received_htlc. clone( ) , ( ) ) , ( offered_htlc. clone( ) , ( ) ) ] ;
2086
2076
let tx = builder. build ( 3000 , 0 ) ;
2087
- let keys = & builder . keys . clone ( ) ;
2077
+ let keys = tx . trust ( ) . keys ( ) ;
2088
2078
assert_eq ! ( tx. built. transaction. output. len( ) , 3 ) ;
2089
2079
assert_eq ! ( tx. built. transaction. output[ 0 ] . script_pubkey, get_htlc_redeemscript( & received_htlc, & ChannelTypeFeatures :: only_static_remote_key( ) , & keys) . to_p2wsh( ) ) ;
2090
2080
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