@@ -93,6 +93,9 @@ pub struct HTLCDescriptor {
9393 pub commitment_txid : Txid ,
9494 /// The number of the commitment transaction in which the HTLC output lives.
9595 pub per_commitment_number : u64 ,
96+ /// The public key corresponding to the number of the commitment transaction in which the HTLC
97+ /// output lives.
98+ pub per_commitment_point : PublicKey ,
9699 /// The details of the HTLC as it appears in the commitment transaction.
97100 pub htlc : HTLCOutputInCommitment ,
98101 /// The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
@@ -111,17 +114,15 @@ impl HTLCDescriptor {
111114
112115 /// Returns the delayed output created as a result of spending the HTLC output in the commitment
113116 /// transaction.
114- pub fn tx_output < C : secp256k1:: Signing + secp256k1:: Verification > (
115- & self , per_commitment_point : & PublicKey , secp : & Secp256k1 < C >
116- ) -> TxOut {
117+ pub fn tx_output < C : secp256k1:: Signing + secp256k1:: Verification > ( & self , secp : & Secp256k1 < C > ) -> TxOut {
117118 let channel_params = self . channel_parameters . as_holder_broadcastable ( ) ;
118119 let broadcaster_keys = channel_params. broadcaster_pubkeys ( ) ;
119120 let counterparty_keys = channel_params. countersignatory_pubkeys ( ) ;
120121 let broadcaster_delayed_key = chan_utils:: derive_public_key (
121- secp, per_commitment_point, & broadcaster_keys. delayed_payment_basepoint
122+ secp, & self . per_commitment_point , & broadcaster_keys. delayed_payment_basepoint
122123 ) ;
123124 let counterparty_revocation_key = chan_utils:: derive_public_revocation_key (
124- secp, per_commitment_point, & counterparty_keys. revocation_basepoint
125+ secp, & self . per_commitment_point , & counterparty_keys. revocation_basepoint
125126 ) ;
126127 chan_utils:: build_htlc_output (
127128 0 /* feerate_per_kw */ , channel_params. contest_delay ( ) , & self . htlc ,
@@ -130,20 +131,18 @@ impl HTLCDescriptor {
130131 }
131132
132133 /// Returns the witness script of the HTLC output in the commitment transaction.
133- pub fn witness_script < C : secp256k1:: Signing + secp256k1:: Verification > (
134- & self , per_commitment_point : & PublicKey , secp : & Secp256k1 < C >
135- ) -> Script {
134+ pub fn witness_script < C : secp256k1:: Signing + secp256k1:: Verification > ( & self , secp : & Secp256k1 < C > ) -> Script {
136135 let channel_params = self . channel_parameters . as_holder_broadcastable ( ) ;
137136 let broadcaster_keys = channel_params. broadcaster_pubkeys ( ) ;
138137 let counterparty_keys = channel_params. countersignatory_pubkeys ( ) ;
139138 let broadcaster_htlc_key = chan_utils:: derive_public_key (
140- secp, per_commitment_point, & broadcaster_keys. htlc_basepoint
139+ secp, & self . per_commitment_point , & broadcaster_keys. htlc_basepoint
141140 ) ;
142141 let counterparty_htlc_key = chan_utils:: derive_public_key (
143- secp, per_commitment_point, & counterparty_keys. htlc_basepoint
142+ secp, & self . per_commitment_point , & counterparty_keys. htlc_basepoint
144143 ) ;
145144 let counterparty_revocation_key = chan_utils:: derive_public_revocation_key (
146- secp, per_commitment_point, & counterparty_keys. revocation_basepoint
145+ secp, & self . per_commitment_point , & counterparty_keys. revocation_basepoint
147146 ) ;
148147 chan_utils:: get_htlc_redeemscript_with_explicit_keys (
149148 & self . htlc , & ChannelTypeFeatures :: anchors_zero_htlc_fee_and_dependencies ( ) , & broadcaster_htlc_key, & counterparty_htlc_key,
@@ -696,15 +695,12 @@ where
696695 let mut signers = HashMap :: new ( ) ;
697696 let mut must_spend = Vec :: with_capacity ( htlc_descriptors. len ( ) ) ;
698697 for htlc_descriptor in htlc_descriptors {
699- let signer = signers. entry ( htlc_descriptor. channel_keys_id )
698+ signers. entry ( htlc_descriptor. channel_keys_id )
700699 . or_insert_with ( ||
701700 self . signer_provider . derive_channel_signer (
702701 htlc_descriptor. channel_value_satoshis , htlc_descriptor. channel_keys_id ,
703702 )
704703 ) ;
705- let per_commitment_point = signer. get_per_commitment_point (
706- htlc_descriptor. per_commitment_number , & self . secp
707- ) ;
708704
709705 let htlc_input = htlc_descriptor. unsigned_tx_input ( ) ;
710706 must_spend. push ( Input {
@@ -716,7 +712,7 @@ where
716712 } ,
717713 } ) ;
718714 tx. input . push ( htlc_input) ;
719- let htlc_output = htlc_descriptor. tx_output ( & per_commitment_point , & self . secp ) ;
715+ let htlc_output = htlc_descriptor. tx_output ( & self . secp ) ;
720716 tx. output . push ( htlc_output) ;
721717 }
722718
@@ -743,10 +739,7 @@ where
743739 let htlc_sig = signer. sign_holder_htlc_transaction (
744740 & htlc_tx, idx, htlc_descriptor, & self . secp
745741 ) ?;
746- let per_commitment_point = signer. get_per_commitment_point (
747- htlc_descriptor. per_commitment_number , & self . secp
748- ) ;
749- let witness_script = htlc_descriptor. witness_script ( & per_commitment_point, & self . secp ) ;
742+ let witness_script = htlc_descriptor. witness_script ( & self . secp ) ;
750743 htlc_tx. input [ idx] . witness = htlc_descriptor. tx_input_witness ( & htlc_sig, & witness_script) ;
751744 }
752745
0 commit comments