@@ -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 ) ) ?;
@@ -1217,12 +1213,8 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1217
1213
// If we've detected a counterparty commitment tx on chain, we must include it in the set
1218
1214
// of outputs to watch for spends of, otherwise we're likely to lose user funds. Because
1219
1215
// 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" ) ;
1226
1218
}
1227
1219
& self . outputs_to_watch
1228
1220
}
@@ -1328,7 +1320,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1328
1320
// We're definitely a counterparty commitment transaction!
1329
1321
log_trace ! ( logger, "Got broadcast of revoked counterparty commitment transaction, going to generate general spend tx with {} inputs" , claimable_outpoints. len( ) ) ;
1330
1322
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) ;
1332
1324
1333
1325
macro_rules! check_htlc_fails {
1334
1326
( $txid: expr, $commitment_tx: expr) => {
@@ -1375,7 +1367,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1375
1367
// not being generated by the above conditional. Thus, to be safe, we go ahead and
1376
1368
// insert it here.
1377
1369
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) ;
1379
1371
1380
1372
log_trace ! ( logger, "Got broadcast of non-revoked counterparty commitment transaction {}" , commitment_txid) ;
1381
1373
@@ -1713,7 +1705,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
1713
1705
claimable_outpoints. append ( & mut new_outpoints) ;
1714
1706
}
1715
1707
} 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 ) {
1717
1709
let ( mut new_outpoints, new_outputs_option) = self . check_spend_counterparty_htlc ( & tx, commitment_number, height, & logger) ;
1718
1710
claimable_outpoints. append ( & mut new_outpoints) ;
1719
1711
if let Some ( new_outputs) = new_outputs_option {
@@ -2205,12 +2197,7 @@ impl<ChanSigner: ChannelKeys + Readable> Readable for (BlockHash, ChannelMonitor
2205
2197
for _ in 0 ..counterparty_commitment_txn_on_chain_len {
2206
2198
let txid: Txid = Readable :: read ( reader) ?;
2207
2199
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) {
2214
2201
return Err ( DecodeError :: InvalidValue ) ;
2215
2202
}
2216
2203
}
0 commit comments