@@ -631,7 +631,7 @@ pub struct ChannelMonitor<ChanSigner: ChannelKeys> {
631
631
/// spending. Thus, in order to claim them via revocation key, we track all the counterparty
632
632
/// commitment transactions which we find on-chain, mapping them to the commitment number which
633
633
/// 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 > ,
635
635
/// Cache used to make pruning of payment_preimages faster.
636
636
/// Maps payment_hash values to commitment numbers for counterparty transactions for non-revoked
637
637
/// counterparty transactions (ie should remain pretty small).
@@ -824,13 +824,9 @@ impl<ChanSigner: ChannelKeys + Writeable> ChannelMonitor<ChanSigner> {
824
824
}
825
825
826
826
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 ( ) {
828
828
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) ) ?;
834
830
}
835
831
836
832
writer. write_all ( & byte_utils:: be64_to_array ( self . counterparty_hash_commitment_number . len ( ) as u64 ) ) ?;
@@ -1215,12 +1211,8 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1215
1211
/// (C-not exported) because we have no HashMap bindings
1216
1212
pub fn get_outputs_to_watch ( & self ) -> & HashMap < Txid , Vec < Script > > {
1217
1213
#[ cfg( any( test, feature = "fuzztarget" ) ) ]
1218
- for ( txid, & ( _, ref outputs) ) in self . counterparty_commitment_txn_on_chain . iter ( ) {
1219
- let watched_outputs = self . outputs_to_watch . get ( txid) . expect ( "Counterparty commitment txn which have been broadcast should have outputs registered" ) ;
1220
- assert_eq ! ( watched_outputs. len( ) , outputs. len( ) ) ;
1221
- for ( watched, output) in watched_outputs. iter ( ) . zip ( outputs. iter ( ) ) {
1222
- assert_eq ! ( watched, output) ;
1223
- }
1214
+ for ( txid, _) in self . counterparty_commitment_txn_on_chain . iter ( ) {
1215
+ self . outputs_to_watch . get ( txid) . expect ( "Counterparty commitment txn which have been broadcast should have outputs registered" ) ;
1224
1216
}
1225
1217
& self . outputs_to_watch
1226
1218
}
@@ -1326,7 +1318,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1326
1318
// We're definitely a counterparty commitment transaction!
1327
1319
log_trace ! ( logger, "Got broadcast of revoked counterparty commitment transaction, going to generate general spend tx with {} inputs" , claimable_outpoints. len( ) ) ;
1328
1320
watch_outputs. append ( & mut tx. output . clone ( ) ) ;
1329
- self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, ( commitment_number, tx . output . iter ( ) . map ( |output| { output . script_pubkey . clone ( ) } ) . collect ( ) ) ) ;
1321
+ self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
1330
1322
1331
1323
macro_rules! check_htlc_fails {
1332
1324
( $txid: expr, $commitment_tx: expr) => {
@@ -1373,7 +1365,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1373
1365
// not being generated by the above conditional. Thus, to be safe, we go ahead and
1374
1366
// insert it here.
1375
1367
watch_outputs. append ( & mut tx. output . clone ( ) ) ;
1376
- self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, ( commitment_number, tx . output . iter ( ) . map ( |output| { output . script_pubkey . clone ( ) } ) . collect ( ) ) ) ;
1368
+ self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
1377
1369
1378
1370
log_trace ! ( logger, "Got broadcast of non-revoked counterparty commitment transaction {}" , commitment_txid) ;
1379
1371
@@ -1711,7 +1703,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1711
1703
claimable_outpoints. append ( & mut new_outpoints) ;
1712
1704
}
1713
1705
} else {
1714
- if let Some ( & ( commitment_number, _ ) ) = self . counterparty_commitment_txn_on_chain . get ( & prevout. txid ) {
1706
+ if let Some ( & commitment_number) = self . counterparty_commitment_txn_on_chain . get ( & prevout. txid ) {
1715
1707
let ( mut new_outpoints, new_outputs_option) = self . check_spend_counterparty_htlc ( & tx, commitment_number, height, & logger) ;
1716
1708
claimable_outpoints. append ( & mut new_outpoints) ;
1717
1709
if let Some ( new_outputs) = new_outputs_option {
@@ -2203,12 +2195,7 @@ impl<ChanSigner: ChannelKeys + Readable> Readable for (BlockHash, ChannelMonitor
2203
2195
for _ in 0 ..counterparty_commitment_txn_on_chain_len {
2204
2196
let txid: Txid = Readable :: read ( reader) ?;
2205
2197
let commitment_number = <U48 as Readable >:: read ( reader) ?. 0 ;
2206
- let outputs_count = <u64 as Readable >:: read ( reader) ?;
2207
- let mut outputs = Vec :: with_capacity ( cmp:: min ( outputs_count as usize , MAX_ALLOC_SIZE / 8 ) ) ;
2208
- for _ in 0 ..outputs_count {
2209
- outputs. push ( Readable :: read ( reader) ?) ;
2210
- }
2211
- if let Some ( _) = counterparty_commitment_txn_on_chain. insert ( txid, ( commitment_number, outputs) ) {
2198
+ if let Some ( _) = counterparty_commitment_txn_on_chain. insert ( txid, commitment_number) {
2212
2199
return Err ( DecodeError :: InvalidValue ) ;
2213
2200
}
2214
2201
}
0 commit comments