@@ -3230,21 +3230,22 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
32303230 /// Attempts to claim a counterparty commitment transaction's outputs using the revocation key and
32313231 /// data in counterparty_claimable_outpoints. Will directly claim any HTLC outputs which expire at a
32323232 /// height > height + CLTV_SHARED_CLAIM_BUFFER. In any case, will install monitoring for
3233- /// HTLC-Success/HTLC-Timeout transactions.
3233+ /// HTLC-Success/HTLC-Timeout transactions. This function should only be called when claimbale htlc
3234+ /// data is available in `counterparty_claimable_outpoints`.
32343235 ///
32353236 /// Returns packages to claim the revoked output(s), as well as additional outputs to watch and
32363237 /// general information about the output that is to the counterparty in the commitment
32373238 /// transaction.
3238- fn check_spend_counterparty_transaction < L : Deref > ( & mut self , tx : & Transaction , height : u32 , block_hash : & BlockHash , per_commitment_option : Option < & Vec < ( HTLCOutputInCommitment , Option < Box < HTLCSource > > ) > > , logger : & L )
3239- -> ( Vec < PackageTemplate > , TransactionOutputs , CommitmentTxCounterpartyOutputInfo )
3239+ fn check_spend_counterparty_transaction < L : Deref > ( & mut self , tx : & Transaction , height : u32 , block_hash : & BlockHash , logger : & L )
3240+ -> ( Vec < PackageTemplate > , TransactionOutputs , CommitmentTxCounterpartyOutputInfo )
32403241 where L :: Target : Logger {
32413242 // Most secp and related errors trying to create keys means we have no hope of constructing
32423243 // a spend transaction...so we return no transactions to broadcast
32433244 let mut claimable_outpoints = Vec :: new ( ) ;
32443245 let mut watch_outputs = Vec :: new ( ) ;
32453246 let mut to_counterparty_output_info = None ;
3246-
32473247 let commitment_txid = tx. txid ( ) ; //TODO: This is gonna be a performance bottleneck for watchtowers!
3248+ let per_commitment_option = self . counterparty_claimable_outpoints . get ( & commitment_txid) ;
32483249
32493250 macro_rules! ignore_error {
32503251 ( $thing : expr ) => {
@@ -3775,13 +3776,9 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
37753776 & self . channel_id( ) , txid) ;
37763777 self . funding_spend_seen = true ;
37773778 let mut commitment_tx_to_counterparty_output = None ;
3778-
37793779 if ( tx. input [ 0 ] . sequence . 0 >> 8 * 3 ) as u8 == 0x80 && ( tx. lock_time . to_consensus_u32 ( ) >> 8 * 3 ) as u8 == 0x20 {
3780- let per_commitment_option = self . counterparty_claimable_outpoints . get ( & tx. txid ( ) ) . map ( |x| x. iter ( )
3781- . map ( |& ( ref a, ref b) | ( a. clone ( ) , b. clone ( ) ) ) . collect :: < Vec < _ > > ( ) ) ;
3782-
37833780 let ( mut new_outpoints, new_outputs, counterparty_output_idx_sats) =
3784- self . check_spend_counterparty_transaction ( & tx, height, & block_hash, per_commitment_option . as_ref ( ) , & logger) ;
3781+ self . check_spend_counterparty_transaction ( & tx, height, & block_hash, & logger) ;
37853782 commitment_tx_to_counterparty_output = counterparty_output_idx_sats;
37863783 if !new_outputs. 1 . is_empty ( ) {
37873784 watch_outputs. push ( new_outputs) ;
0 commit comments