@@ -626,7 +626,7 @@ pub struct ChannelMonitor<ChanSigner: ChannelKeys> {
626
626
/// spending. Thus, in order to claim them via revocation key, we track all the counterparty
627
627
/// commitment transactions which we find on-chain, mapping them to the commitment number which
628
628
/// can be used to derive the revocation key and claim the transactions.
629
- counterparty_commitment_txn_on_chain : HashMap < Txid , ( u64 , Vec < Script > ) > ,
629
+ counterparty_commitment_txn_on_chain : HashMap < Txid , u64 > ,
630
630
/// Cache used to make pruning of payment_preimages faster.
631
631
/// Maps payment_hash values to commitment numbers for counterparty transactions for non-revoked
632
632
/// counterparty transactions (ie should remain pretty small).
@@ -819,13 +819,9 @@ impl<ChanSigner: ChannelKeys + Writeable> ChannelMonitor<ChanSigner> {
819
819
}
820
820
821
821
writer. write_all ( & byte_utils:: be64_to_array ( self . counterparty_commitment_txn_on_chain . len ( ) as u64 ) ) ?;
822
- for ( ref txid, & ( commitment_number, ref txouts ) ) in self . counterparty_commitment_txn_on_chain . iter ( ) {
822
+ for ( ref txid, commitment_number) in self . counterparty_commitment_txn_on_chain . iter ( ) {
823
823
writer. write_all ( & txid[ ..] ) ?;
824
- writer. write_all ( & byte_utils:: be48_to_array ( commitment_number) ) ?;
825
- ( txouts. len ( ) as u64 ) . write ( writer) ?;
826
- for script in txouts. iter ( ) {
827
- script. write ( writer) ?;
828
- }
824
+ writer. write_all ( & byte_utils:: be48_to_array ( * commitment_number) ) ?;
829
825
}
830
826
831
827
writer. write_all ( & byte_utils:: be64_to_array ( self . counterparty_hash_commitment_number . len ( ) as u64 ) ) ?;
@@ -1210,12 +1206,8 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1210
1206
/// (C-not exported) because we have no HashMap bindings
1211
1207
pub fn get_outputs_to_watch ( & self ) -> & HashMap < Txid , Vec < Script > > {
1212
1208
#[ cfg( any( test, feature = "fuzztarget" ) ) ]
1213
- for ( txid, & ( _, ref outputs) ) in self . counterparty_commitment_txn_on_chain . iter ( ) {
1214
- let watched_outputs = self . outputs_to_watch . get ( txid) . expect ( "Counterparty commitment txn which have been broadcast should have outputs registered" ) ;
1215
- assert_eq ! ( watched_outputs. len( ) , outputs. len( ) ) ;
1216
- for ( watched, output) in watched_outputs. iter ( ) . zip ( outputs. iter ( ) ) {
1217
- assert_eq ! ( watched, output) ;
1218
- }
1209
+ for ( txid, _) in self . counterparty_commitment_txn_on_chain . iter ( ) {
1210
+ self . outputs_to_watch . get ( txid) . expect ( "Counterparty commitment txn which have been broadcast should have outputs registered" ) ;
1219
1211
}
1220
1212
& self . outputs_to_watch
1221
1213
}
@@ -1321,7 +1313,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1321
1313
// We're definitely a counterparty commitment transaction!
1322
1314
log_trace ! ( logger, "Got broadcast of revoked counterparty commitment transaction, going to generate general spend tx with {} inputs" , claimable_outpoints. len( ) ) ;
1323
1315
watch_outputs. append ( & mut tx. output . clone ( ) ) ;
1324
- self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, ( commitment_number, tx . output . iter ( ) . map ( |output| { output . script_pubkey . clone ( ) } ) . collect ( ) ) ) ;
1316
+ self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
1325
1317
1326
1318
macro_rules! check_htlc_fails {
1327
1319
( $txid: expr, $commitment_tx: expr) => {
@@ -1368,7 +1360,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1368
1360
// not being generated by the above conditional. Thus, to be safe, we go ahead and
1369
1361
// insert it here.
1370
1362
watch_outputs. append ( & mut tx. output . clone ( ) ) ;
1371
- self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, ( commitment_number, tx . output . iter ( ) . map ( |output| { output . script_pubkey . clone ( ) } ) . collect ( ) ) ) ;
1363
+ self . counterparty_commitment_txn_on_chain . insert ( commitment_txid, commitment_number) ;
1372
1364
1373
1365
log_trace ! ( logger, "Got broadcast of non-revoked counterparty commitment transaction {}" , commitment_txid) ;
1374
1366
@@ -1706,7 +1698,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1706
1698
claimable_outpoints. append ( & mut new_outpoints) ;
1707
1699
}
1708
1700
} else {
1709
- if let Some ( & ( commitment_number, _ ) ) = self . counterparty_commitment_txn_on_chain . get ( & prevout. txid ) {
1701
+ if let Some ( & commitment_number) = self . counterparty_commitment_txn_on_chain . get ( & prevout. txid ) {
1710
1702
let ( mut new_outpoints, new_outputs_option) = self . check_spend_counterparty_htlc ( & tx, commitment_number, height, & logger) ;
1711
1703
claimable_outpoints. append ( & mut new_outpoints) ;
1712
1704
if let Some ( new_outputs) = new_outputs_option {
@@ -2198,12 +2190,7 @@ impl<ChanSigner: ChannelKeys + Readable> Readable for (BlockHash, ChannelMonitor
2198
2190
for _ in 0 ..counterparty_commitment_txn_on_chain_len {
2199
2191
let txid: Txid = Readable :: read ( reader) ?;
2200
2192
let commitment_number = <U48 as Readable >:: read ( reader) ?. 0 ;
2201
- let outputs_count = <u64 as Readable >:: read ( reader) ?;
2202
- let mut outputs = Vec :: with_capacity ( cmp:: min ( outputs_count as usize , MAX_ALLOC_SIZE / 8 ) ) ;
2203
- for _ in 0 ..outputs_count {
2204
- outputs. push ( Readable :: read ( reader) ?) ;
2205
- }
2206
- if let Some ( _) = counterparty_commitment_txn_on_chain. insert ( txid, ( commitment_number, outputs) ) {
2193
+ if let Some ( _) = counterparty_commitment_txn_on_chain. insert ( txid, commitment_number) {
2207
2194
return Err ( DecodeError :: InvalidValue ) ;
2208
2195
}
2209
2196
}
0 commit comments