@@ -93,6 +93,9 @@ pub struct HTLCDescriptor {
93
93
pub commitment_txid : Txid ,
94
94
/// The number of the commitment transaction in which the HTLC output lives.
95
95
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 ,
96
99
/// The details of the HTLC as it appears in the commitment transaction.
97
100
pub htlc : HTLCOutputInCommitment ,
98
101
/// The preimage, if `Some`, to claim the HTLC output with. If `None`, the timeout path must be
@@ -111,17 +114,15 @@ impl HTLCDescriptor {
111
114
112
115
/// Returns the delayed output created as a result of spending the HTLC output in the commitment
113
116
/// 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 {
117
118
let channel_params = self . channel_parameters . as_holder_broadcastable ( ) ;
118
119
let broadcaster_keys = channel_params. broadcaster_pubkeys ( ) ;
119
120
let counterparty_keys = channel_params. countersignatory_pubkeys ( ) ;
120
121
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
122
123
) ;
123
124
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
125
126
) ;
126
127
chan_utils:: build_htlc_output (
127
128
0 /* feerate_per_kw */ , channel_params. contest_delay ( ) , & self . htlc ,
@@ -130,20 +131,18 @@ impl HTLCDescriptor {
130
131
}
131
132
132
133
/// 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 {
136
135
let channel_params = self . channel_parameters . as_holder_broadcastable ( ) ;
137
136
let broadcaster_keys = channel_params. broadcaster_pubkeys ( ) ;
138
137
let counterparty_keys = channel_params. countersignatory_pubkeys ( ) ;
139
138
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
141
140
) ;
142
141
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
144
143
) ;
145
144
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
147
146
) ;
148
147
chan_utils:: get_htlc_redeemscript_with_explicit_keys (
149
148
& self . htlc , & ChannelTypeFeatures :: anchors_zero_htlc_fee_and_dependencies ( ) , & broadcaster_htlc_key, & counterparty_htlc_key,
@@ -696,15 +695,12 @@ where
696
695
let mut signers = HashMap :: new ( ) ;
697
696
let mut must_spend = Vec :: with_capacity ( htlc_descriptors. len ( ) ) ;
698
697
for htlc_descriptor in htlc_descriptors {
699
- let signer = signers. entry ( htlc_descriptor. channel_keys_id )
698
+ signers. entry ( htlc_descriptor. channel_keys_id )
700
699
. or_insert_with ( ||
701
700
self . signer_provider . derive_channel_signer (
702
701
htlc_descriptor. channel_value_satoshis , htlc_descriptor. channel_keys_id ,
703
702
)
704
703
) ;
705
- let per_commitment_point = signer. get_per_commitment_point (
706
- htlc_descriptor. per_commitment_number , & self . secp
707
- ) ;
708
704
709
705
let htlc_input = htlc_descriptor. unsigned_tx_input ( ) ;
710
706
must_spend. push ( Input {
@@ -716,7 +712,7 @@ where
716
712
} ,
717
713
} ) ;
718
714
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 ) ;
720
716
tx. output . push ( htlc_output) ;
721
717
}
722
718
@@ -743,10 +739,7 @@ where
743
739
let htlc_sig = signer. sign_holder_htlc_transaction (
744
740
& htlc_tx, idx, htlc_descriptor, & self . secp
745
741
) ?;
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 ) ;
750
743
htlc_tx. input [ idx] . witness = htlc_descriptor. tx_input_witness ( & htlc_sig, & witness_script) ;
751
744
}
752
745
0 commit comments