@@ -3233,16 +3233,14 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3233
3233
/// height > height + CLTV_SHARED_CLAIM_BUFFER. In any case, will install monitoring for
3234
3234
/// HTLC-Success/HTLC-Timeout transactions.
3235
3235
///
3236
- /// Returns packages to claim the revoked output(s), as well as additional outputs to watch and
3237
- /// general information about the output that is to the counterparty in the commitment
3238
- /// transaction.
3236
+ /// Returns packages to claim the revoked output(s) and general information about the output that
3237
+ /// is to the counterparty in the commitment transaction.
3239
3238
fn check_spend_counterparty_transaction < L : Deref > ( & mut self , tx : & Transaction , height : u32 , block_hash : & BlockHash , logger : & L )
3240
- -> ( Vec < PackageTemplate > , TransactionOutputs , CommitmentTxCounterpartyOutputInfo )
3239
+ -> ( Vec < PackageTemplate > , CommitmentTxCounterpartyOutputInfo )
3241
3240
where L :: Target : Logger {
3242
3241
// Most secp and related errors trying to create keys means we have no hope of constructing
3243
3242
// a spend transaction...so we return no transactions to broadcast
3244
3243
let mut claimable_outpoints = Vec :: new ( ) ;
3245
- let mut watch_outputs = Vec :: new ( ) ;
3246
3244
let mut to_counterparty_output_info = None ;
3247
3245
3248
3246
let commitment_txid = tx. txid ( ) ; //TODO: This is gonna be a performance bottleneck for watchtowers!
@@ -3252,7 +3250,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3252
3250
( $thing : expr ) => {
3253
3251
match $thing {
3254
3252
Ok ( a) => a,
3255
- Err ( _) => return ( claimable_outpoints, ( commitment_txid , watch_outputs ) , to_counterparty_output_info)
3253
+ Err ( _) => return ( claimable_outpoints, to_counterparty_output_info)
3256
3254
}
3257
3255
} ;
3258
3256
}
@@ -3286,8 +3284,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3286
3284
if transaction_output_index as usize >= tx. output . len ( ) ||
3287
3285
tx. output [ transaction_output_index as usize ] . value != htlc. to_bitcoin_amount ( ) {
3288
3286
// per_commitment_data is corrupt or our commitment signing key leaked!
3289
- return ( claimable_outpoints, ( commitment_txid, watch_outputs) ,
3290
- to_counterparty_output_info) ;
3287
+ return ( claimable_outpoints, to_counterparty_output_info) ;
3291
3288
}
3292
3289
let revk_htlc_outp = RevokedHTLCOutput :: build ( per_commitment_point, self . counterparty_commitment_params . counterparty_delayed_payment_base_key , self . counterparty_commitment_params . counterparty_htlc_base_key , per_commitment_key, htlc. amount_msat / 1000 , htlc. clone ( ) , & self . onchain_tx_handler . channel_transaction_parameters . channel_type_features ) ;
3293
3290
let justice_package = PackageTemplate :: build_package ( commitment_txid, transaction_output_index, PackageSolvingData :: RevokedHTLCOutput ( revk_htlc_outp) , htlc. cltv_expiry , height) ;
@@ -3300,9 +3297,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3300
3297
if !claimable_outpoints. is_empty ( ) || per_commitment_option. is_some ( ) { // ie we're confident this is actually ours
3301
3298
// We're definitely a counterparty commitment transaction!
3302
3299
log_error ! ( logger, "Got broadcast of revoked counterparty commitment transaction, going to generate general spend tx with {} inputs" , claimable_outpoints. len( ) ) ;
3303
- for ( idx, outp) in tx. output . iter ( ) . enumerate ( ) {
3304
- watch_outputs. push ( ( idx as u32 , outp. clone ( ) ) ) ;
3305
- }
3306
3300
self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
3307
3301
3308
3302
if let Some ( per_commitment_claimable_data) = per_commitment_option {
@@ -3328,9 +3322,6 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3328
3322
// already processed the block, resulting in the counterparty_commitment_txn_on_chain entry
3329
3323
// not being generated by the above conditional. Thus, to be safe, we go ahead and
3330
3324
// insert it here.
3331
- for ( idx, outp) in tx. output . iter ( ) . enumerate ( ) {
3332
- watch_outputs. push ( ( idx as u32 , outp. clone ( ) ) ) ;
3333
- }
3334
3325
self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
3335
3326
3336
3327
log_info ! ( logger, "Got broadcast of non-revoked counterparty commitment transaction {}" , commitment_txid) ;
@@ -3346,7 +3337,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3346
3337
}
3347
3338
3348
3339
}
3349
- ( claimable_outpoints, ( commitment_txid , watch_outputs ) , to_counterparty_output_info)
3340
+ ( claimable_outpoints, to_counterparty_output_info)
3350
3341
}
3351
3342
3352
3343
/// Returns the HTLC claim package templates and the counterparty output info
@@ -3778,24 +3769,25 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
3778
3769
self . funding_spend_seen = true ;
3779
3770
let mut commitment_tx_to_counterparty_output = None ;
3780
3771
if ( tx. input [ 0 ] . sequence . 0 >> 8 * 3 ) as u8 == 0x80 && ( tx. lock_time . to_consensus_u32 ( ) >> 8 * 3 ) as u8 == 0x20 {
3781
- let ( mut new_outpoints, new_outputs, counterparty_output_idx_sats) =
3782
- self . check_spend_counterparty_transaction ( & tx, height, & block_hash, & logger) ;
3783
- commitment_tx_to_counterparty_output = counterparty_output_idx_sats;
3784
- if !new_outputs. 1 . is_empty ( ) {
3785
- watch_outputs. push ( new_outputs) ;
3786
- }
3787
- claimable_outpoints. append ( & mut new_outpoints) ;
3788
- if new_outpoints. is_empty ( ) {
3789
- if let Some ( ( mut new_outpoints, new_outputs) ) = self . check_spend_holder_transaction ( & tx, height, & block_hash, & logger) {
3790
- #[ cfg( not( fuzzing) ) ]
3791
- debug_assert ! ( commitment_tx_to_counterparty_output. is_none( ) ,
3792
- "A commitment transaction matched as both a counterparty and local commitment tx?" ) ;
3793
- if !new_outputs. 1 . is_empty ( ) {
3794
- watch_outputs. push ( new_outputs) ;
3795
- }
3796
- claimable_outpoints. append ( & mut new_outpoints) ;
3797
- balance_spendable_csv = Some ( self . on_holder_tx_csv ) ;
3772
+ if let Some ( ( mut new_outpoints, new_outputs) ) = self . check_spend_holder_transaction ( & tx, height, & block_hash, & logger) {
3773
+ if !new_outputs. 1 . is_empty ( ) {
3774
+ watch_outputs. push ( new_outputs) ;
3775
+ }
3776
+
3777
+ claimable_outpoints. append ( & mut new_outpoints) ;
3778
+ balance_spendable_csv = Some ( self . on_holder_tx_csv ) ;
3779
+ } else {
3780
+ let mut new_watch_outputs = Vec :: new ( ) ;
3781
+ for ( idx, outp) in tx. output . iter ( ) . enumerate ( ) {
3782
+ new_watch_outputs. push ( ( idx as u32 , outp. clone ( ) ) ) ;
3798
3783
}
3784
+ watch_outputs. push ( ( txid, new_watch_outputs) ) ;
3785
+
3786
+ let ( mut new_outpoints, counterparty_output_idx_sats) =
3787
+ self . check_spend_counterparty_transaction ( & tx, height, & block_hash, & logger) ;
3788
+ commitment_tx_to_counterparty_output = counterparty_output_idx_sats;
3789
+
3790
+ claimable_outpoints. append ( & mut new_outpoints) ;
3799
3791
}
3800
3792
}
3801
3793
self . onchain_events_awaiting_threshold_conf . push ( OnchainEventEntry {
0 commit comments