@@ -220,12 +220,7 @@ pub struct OnchainTxHandler<ChannelSigner: WriteableEcdsaChannelSigner> {
220
220
channel_keys_id : [ u8 ; 32 ] ,
221
221
destination_script : Script ,
222
222
holder_commitment : HolderCommitmentTransaction ,
223
- // holder_htlc_sigs and prev_holder_htlc_sigs are in the order as they appear in the commitment
224
- // transaction outputs (hence the Option<>s inside the Vec). The first usize is the index in
225
- // the set of HTLCs in the HolderCommitmentTransaction.
226
- holder_htlc_sigs : Option < Vec < Option < ( usize , Signature ) > > > ,
227
223
prev_holder_commitment : Option < HolderCommitmentTransaction > ,
228
- prev_holder_htlc_sigs : Option < Vec < Option < ( usize , Signature ) > > > ,
229
224
230
225
pub ( super ) signer : ChannelSigner ,
231
226
pub ( crate ) channel_transaction_parameters : ChannelTransactionParameters ,
@@ -283,9 +278,7 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> PartialEq for OnchainTxHandler<
283
278
self . channel_keys_id == other. channel_keys_id &&
284
279
self . destination_script == other. destination_script &&
285
280
self . holder_commitment == other. holder_commitment &&
286
- self . holder_htlc_sigs == other. holder_htlc_sigs &&
287
281
self . prev_holder_commitment == other. prev_holder_commitment &&
288
- self . prev_holder_htlc_sigs == other. prev_holder_htlc_sigs &&
289
282
self . channel_transaction_parameters == other. channel_transaction_parameters &&
290
283
self . pending_claim_requests == other. pending_claim_requests &&
291
284
self . claimable_outpoints == other. claimable_outpoints &&
@@ -303,9 +296,9 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
303
296
304
297
self . destination_script . write ( writer) ?;
305
298
self . holder_commitment . write ( writer) ?;
306
- self . holder_htlc_sigs . write ( writer) ?;
299
+ None :: < Option < Vec < Option < ( usize , Signature ) > > > > . write ( writer) ?; // holder_htlc_sigs
307
300
self . prev_holder_commitment . write ( writer) ?;
308
- self . prev_holder_htlc_sigs . write ( writer) ?;
301
+ None :: < Option < Vec < Option < ( usize , Signature ) > > > > . write ( writer) ?; // prev_holder_htlc_sigs
309
302
310
303
self . channel_transaction_parameters . write ( writer) ?;
311
304
@@ -360,9 +353,9 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
360
353
let destination_script = Readable :: read ( reader) ?;
361
354
362
355
let holder_commitment = Readable :: read ( reader) ?;
363
- let holder_htlc_sigs = Readable :: read ( reader) ?;
356
+ let _holder_htlc_sigs : Option < Vec < Option < ( usize , Signature ) > > > = Readable :: read ( reader) ?;
364
357
let prev_holder_commitment = Readable :: read ( reader) ?;
365
- let prev_holder_htlc_sigs = Readable :: read ( reader) ?;
358
+ let _prev_holder_htlc_sigs : Option < Vec < Option < ( usize , Signature ) > > > = Readable :: read ( reader) ?;
366
359
367
360
let channel_parameters = Readable :: read ( reader) ?;
368
361
@@ -427,9 +420,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
427
420
channel_keys_id,
428
421
destination_script,
429
422
holder_commitment,
430
- holder_htlc_sigs,
431
423
prev_holder_commitment,
432
- prev_holder_htlc_sigs,
433
424
signer,
434
425
channel_transaction_parameters : channel_parameters,
435
426
claimable_outpoints,
@@ -453,9 +444,7 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
453
444
channel_keys_id,
454
445
destination_script,
455
446
holder_commitment,
456
- holder_htlc_sigs : None ,
457
447
prev_holder_commitment : None ,
458
- prev_holder_htlc_sigs : None ,
459
448
signer,
460
449
channel_transaction_parameters : channel_parameters,
461
450
pending_claim_requests : HashMap :: new ( ) ,
@@ -1101,39 +1090,6 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
1101
1090
1102
1091
pub ( crate ) fn provide_latest_holder_tx ( & mut self , tx : HolderCommitmentTransaction ) {
1103
1092
self . prev_holder_commitment = Some ( replace ( & mut self . holder_commitment , tx) ) ;
1104
- self . holder_htlc_sigs = None ;
1105
- }
1106
-
1107
- // Normally holder HTLCs are signed at the same time as the holder commitment tx. However,
1108
- // in some configurations, the holder commitment tx has been signed and broadcast by a
1109
- // ChannelMonitor replica, so we handle that case here.
1110
- fn sign_latest_holder_htlcs ( & mut self ) {
1111
- if self . holder_htlc_sigs . is_none ( ) {
1112
- let ( _sig, sigs) = self . signer . sign_holder_commitment_and_htlcs ( & self . holder_commitment , & self . secp_ctx ) . expect ( "sign holder commitment" ) ;
1113
- self . holder_htlc_sigs = Some ( Self :: extract_holder_sigs ( & self . holder_commitment , sigs) ) ;
1114
- }
1115
- }
1116
-
1117
- // Normally only the latest commitment tx and HTLCs need to be signed. However, in some
1118
- // configurations we may have updated our holder commitment but a replica of the ChannelMonitor
1119
- // broadcast the previous one before we sync with it. We handle that case here.
1120
- fn sign_prev_holder_htlcs ( & mut self ) {
1121
- if self . prev_holder_htlc_sigs . is_none ( ) {
1122
- if let Some ( ref holder_commitment) = self . prev_holder_commitment {
1123
- let ( _sig, sigs) = self . signer . sign_holder_commitment_and_htlcs ( holder_commitment, & self . secp_ctx ) . expect ( "sign previous holder commitment" ) ;
1124
- self . prev_holder_htlc_sigs = Some ( Self :: extract_holder_sigs ( holder_commitment, sigs) ) ;
1125
- }
1126
- }
1127
- }
1128
-
1129
- fn extract_holder_sigs ( holder_commitment : & HolderCommitmentTransaction , sigs : Vec < Signature > ) -> Vec < Option < ( usize , Signature ) > > {
1130
- let mut ret = Vec :: new ( ) ;
1131
- for ( htlc_idx, ( holder_sig, htlc) ) in sigs. iter ( ) . zip ( holder_commitment. htlcs ( ) . iter ( ) ) . enumerate ( ) {
1132
- let tx_idx = htlc. transaction_output_index . unwrap ( ) ;
1133
- if ret. len ( ) <= tx_idx as usize { ret. resize ( tx_idx as usize + 1 , None ) ; }
1134
- ret[ tx_idx as usize ] = Some ( ( htlc_idx, holder_sig. clone ( ) ) ) ;
1135
- }
1136
- ret
1137
1093
}
1138
1094
1139
1095
pub ( crate ) fn get_unsigned_holder_commitment_tx ( & self ) -> & Transaction {
@@ -1145,15 +1101,13 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
1145
1101
// before providing a initial commitment transaction. For outbound channel, init ChannelMonitor at Channel::funding_signed, there is nothing
1146
1102
// to monitor before.
1147
1103
pub ( crate ) fn get_fully_signed_holder_tx ( & mut self , funding_redeemscript : & Script ) -> Transaction {
1148
- let ( sig, htlc_sigs) = self . signer . sign_holder_commitment_and_htlcs ( & self . holder_commitment , & self . secp_ctx ) . expect ( "signing holder commitment" ) ;
1149
- self . holder_htlc_sigs = Some ( Self :: extract_holder_sigs ( & self . holder_commitment , htlc_sigs) ) ;
1104
+ let ( sig, _) = self . signer . sign_holder_commitment_and_htlcs ( & self . holder_commitment , & self . secp_ctx ) . expect ( "signing holder commitment" ) ;
1150
1105
self . holder_commitment . add_holder_sig ( funding_redeemscript, sig)
1151
1106
}
1152
1107
1153
1108
#[ cfg( any( test, feature="unsafe_revoked_tx_signing" ) ) ]
1154
1109
pub ( crate ) fn get_fully_signed_copy_holder_tx ( & mut self , funding_redeemscript : & Script ) -> Transaction {
1155
- let ( sig, htlc_sigs) = self . signer . unsafe_sign_holder_commitment_and_htlcs ( & self . holder_commitment , & self . secp_ctx ) . expect ( "sign holder commitment" ) ;
1156
- self . holder_htlc_sigs = Some ( Self :: extract_holder_sigs ( & self . holder_commitment , htlc_sigs) ) ;
1110
+ let ( sig, _) = self . signer . unsafe_sign_holder_commitment_and_htlcs ( & self . holder_commitment , & self . secp_ctx ) . expect ( "sign holder commitment" ) ;
1157
1111
self . holder_commitment . add_holder_sig ( funding_redeemscript, sig)
1158
1112
}
1159
1113
@@ -1238,18 +1192,4 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
1238
1192
pub ( crate ) fn channel_type_features ( & self ) -> & ChannelTypeFeatures {
1239
1193
& self . channel_transaction_parameters . channel_type_features
1240
1194
}
1241
-
1242
- #[ cfg( any( test, feature = "unsafe_revoked_tx_signing" ) ) ]
1243
- pub ( crate ) fn unsafe_get_fully_signed_htlc_tx ( & mut self , outp : & :: bitcoin:: OutPoint , preimage : & Option < PaymentPreimage > ) -> Option < Transaction > {
1244
- let latest_had_sigs = self . holder_htlc_sigs . is_some ( ) ;
1245
- let prev_had_sigs = self . prev_holder_htlc_sigs . is_some ( ) ;
1246
- let ret = self . get_fully_signed_htlc_tx ( outp, preimage) ;
1247
- if !latest_had_sigs {
1248
- self . holder_htlc_sigs = None ;
1249
- }
1250
- if !prev_had_sigs {
1251
- self . prev_holder_htlc_sigs = None ;
1252
- }
1253
- ret
1254
- }
1255
1195
}
0 commit comments