@@ -631,7 +631,7 @@ pub struct ChannelMonitor<ChanSigner: ChannelKeys> {
631631 /// spending. Thus, in order to claim them via revocation key, we track all the counterparty
632632 /// commitment transactions which we find on-chain, mapping them to the commitment number which
633633 /// can be used to derive the revocation key and claim the transactions.
634- counterparty_commitment_txn_on_chain : HashMap < Txid , ( u64 , Vec < Script > ) > ,
634+ counterparty_commitment_txn_on_chain : HashMap < Txid , u64 > ,
635635 /// Cache used to make pruning of payment_preimages faster.
636636 /// Maps payment_hash values to commitment numbers for counterparty transactions for non-revoked
637637 /// counterparty transactions (ie should remain pretty small).
@@ -824,13 +824,9 @@ impl<ChanSigner: ChannelKeys + Writeable> ChannelMonitor<ChanSigner> {
824824 }
825825
826826 writer. write_all ( & byte_utils:: be64_to_array ( self . counterparty_commitment_txn_on_chain . len ( ) as u64 ) ) ?;
827- for ( ref txid, & ( commitment_number, ref txouts ) ) in self . counterparty_commitment_txn_on_chain . iter ( ) {
827+ for ( ref txid, commitment_number) in self . counterparty_commitment_txn_on_chain . iter ( ) {
828828 writer. write_all ( & txid[ ..] ) ?;
829- writer. write_all ( & byte_utils:: be48_to_array ( commitment_number) ) ?;
830- ( txouts. len ( ) as u64 ) . write ( writer) ?;
831- for script in txouts. iter ( ) {
832- script. write ( writer) ?;
833- }
829+ writer. write_all ( & byte_utils:: be48_to_array ( * commitment_number) ) ?;
834830 }
835831
836832 writer. write_all ( & byte_utils:: be64_to_array ( self . counterparty_hash_commitment_number . len ( ) as u64 ) ) ?;
@@ -1217,12 +1213,8 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
12171213 // If we've detected a counterparty commitment tx on chain, we must include it in the set
12181214 // of outputs to watch for spends of, otherwise we're likely to lose user funds. Because
12191215 // its trivial to do, double-check that here.
1220- for ( txid, & ( _, ref outputs) ) in self . counterparty_commitment_txn_on_chain . iter ( ) {
1221- let watched_outputs = self . outputs_to_watch . get ( txid) . expect ( "Counterparty commitment txn which have been broadcast should have outputs registered" ) ;
1222- assert_eq ! ( watched_outputs. len( ) , outputs. len( ) ) ;
1223- for ( watched, output) in watched_outputs. iter ( ) . zip ( outputs. iter ( ) ) {
1224- assert_eq ! ( watched, output) ;
1225- }
1216+ for ( txid, _) in self . counterparty_commitment_txn_on_chain . iter ( ) {
1217+ self . outputs_to_watch . get ( txid) . expect ( "Counterparty commitment txn which have been broadcast should have outputs registered" ) ;
12261218 }
12271219 & self . outputs_to_watch
12281220 }
@@ -1328,7 +1320,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
13281320 // We're definitely a counterparty commitment transaction!
13291321 log_trace ! ( logger, "Got broadcast of revoked counterparty commitment transaction, going to generate general spend tx with {} inputs" , claimable_outpoints. len( ) ) ;
13301322 watch_outputs. append ( & mut tx. output . clone ( ) ) ;
1331- self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, ( commitment_number, tx . output . iter ( ) . map ( |output| { output . script_pubkey . clone ( ) } ) . collect ( ) ) ) ;
1323+ self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
13321324
13331325 macro_rules! check_htlc_fails {
13341326 ( $txid: expr, $commitment_tx: expr) => {
@@ -1375,7 +1367,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
13751367 // not being generated by the above conditional. Thus, to be safe, we go ahead and
13761368 // insert it here.
13771369 watch_outputs. append ( & mut tx. output . clone ( ) ) ;
1378- self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, ( commitment_number, tx . output . iter ( ) . map ( |output| { output . script_pubkey . clone ( ) } ) . collect ( ) ) ) ;
1370+ self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
13791371
13801372 log_trace ! ( logger, "Got broadcast of non-revoked counterparty commitment transaction {}" , commitment_txid) ;
13811373
@@ -1713,7 +1705,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
17131705 claimable_outpoints. append ( & mut new_outpoints) ;
17141706 }
17151707 } else {
1716- if let Some ( & ( commitment_number, _ ) ) = self . counterparty_commitment_txn_on_chain . get ( & prevout. txid ) {
1708+ if let Some ( & commitment_number) = self . counterparty_commitment_txn_on_chain . get ( & prevout. txid ) {
17171709 let ( mut new_outpoints, new_outputs_option) = self . check_spend_counterparty_htlc ( & tx, commitment_number, height, & logger) ;
17181710 claimable_outpoints. append ( & mut new_outpoints) ;
17191711 if let Some ( new_outputs) = new_outputs_option {
@@ -2205,12 +2197,7 @@ impl<ChanSigner: ChannelKeys + Readable> Readable for (BlockHash, ChannelMonitor
22052197 for _ in 0 ..counterparty_commitment_txn_on_chain_len {
22062198 let txid: Txid = Readable :: read ( reader) ?;
22072199 let commitment_number = <U48 as Readable >:: read ( reader) ?. 0 ;
2208- let outputs_count = <u64 as Readable >:: read ( reader) ?;
2209- let mut outputs = Vec :: with_capacity ( cmp:: min ( outputs_count as usize , MAX_ALLOC_SIZE / 8 ) ) ;
2210- for _ in 0 ..outputs_count {
2211- outputs. push ( Readable :: read ( reader) ?) ;
2212- }
2213- if let Some ( _) = counterparty_commitment_txn_on_chain. insert ( txid, ( commitment_number, outputs) ) {
2200+ if let Some ( _) = counterparty_commitment_txn_on_chain. insert ( txid, commitment_number) {
22142201 return Err ( DecodeError :: InvalidValue ) ;
22152202 }
22162203 }
0 commit comments