@@ -297,19 +297,11 @@ struct CounterpartyCommitmentTransaction {
297
297
counterparty_delayed_payment_base_key : PublicKey ,
298
298
counterparty_htlc_base_key : PublicKey ,
299
299
on_counterparty_tx_csv : u16 ,
300
- per_htlc : HashMap < Txid , Vec < HTLCOutputInCommitment > >
301
300
}
302
301
303
302
impl Writeable for CounterpartyCommitmentTransaction {
304
303
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
305
- w. write_all ( & byte_utils:: be64_to_array ( self . per_htlc . len ( ) as u64 ) ) ?;
306
- for ( ref txid, ref htlcs) in self . per_htlc . iter ( ) {
307
- w. write_all ( & txid[ ..] ) ?;
308
- w. write_all ( & byte_utils:: be64_to_array ( htlcs. len ( ) as u64 ) ) ?;
309
- for & ref htlc in htlcs. iter ( ) {
310
- htlc. write ( w) ?;
311
- }
312
- }
304
+ w. write_all ( & byte_utils:: be64_to_array ( 0 ) ) ?;
313
305
write_tlv_fields ! ( w, {
314
306
( 0 , self . counterparty_delayed_payment_base_key, required) ,
315
307
( 2 , self . counterparty_htlc_base_key, required) ,
@@ -321,20 +313,17 @@ impl Writeable for CounterpartyCommitmentTransaction {
321
313
impl Readable for CounterpartyCommitmentTransaction {
322
314
fn read < R : io:: Read > ( r : & mut R ) -> Result < Self , DecodeError > {
323
315
let counterparty_commitment_transaction = {
316
+ // Versions prior to 0.0.100 had some per-HTLC state stored here, which is no longer
317
+ // used. Read it for compatibility.
324
318
let per_htlc_len: u64 = Readable :: read ( r) ?;
325
- let mut per_htlc = HashMap :: with_capacity ( cmp:: min ( per_htlc_len as usize , MAX_ALLOC_SIZE / 64 ) ) ;
326
319
for _ in 0 ..per_htlc_len {
327
- let txid : Txid = Readable :: read ( r) ?;
320
+ let _txid : Txid = Readable :: read ( r) ?;
328
321
let htlcs_count: u64 = Readable :: read ( r) ?;
329
- let mut htlcs = Vec :: with_capacity ( cmp:: min ( htlcs_count as usize , MAX_ALLOC_SIZE / 32 ) ) ;
330
322
for _ in 0 ..htlcs_count {
331
- let htlc = Readable :: read ( r) ?;
332
- htlcs. push ( htlc) ;
333
- }
334
- if let Some ( _) = per_htlc. insert ( txid, htlcs) {
335
- return Err ( DecodeError :: InvalidValue ) ;
323
+ let _htlc: HTLCOutputInCommitment = Readable :: read ( r) ?;
336
324
}
337
325
}
326
+
338
327
let mut counterparty_delayed_payment_base_key = OptionDeserWrapper ( None ) ;
339
328
let mut counterparty_htlc_base_key = OptionDeserWrapper ( None ) ;
340
329
let mut on_counterparty_tx_csv: u16 = 0 ;
@@ -347,7 +336,6 @@ impl Readable for CounterpartyCommitmentTransaction {
347
336
counterparty_delayed_payment_base_key : counterparty_delayed_payment_base_key. 0 . unwrap ( ) ,
348
337
counterparty_htlc_base_key : counterparty_htlc_base_key. 0 . unwrap ( ) ,
349
338
on_counterparty_tx_csv,
350
- per_htlc,
351
339
}
352
340
} ;
353
341
Ok ( counterparty_commitment_transaction)
@@ -855,7 +843,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
855
843
let counterparty_channel_parameters = channel_parameters. counterparty_parameters . as_ref ( ) . unwrap ( ) ;
856
844
let counterparty_delayed_payment_base_key = counterparty_channel_parameters. pubkeys . delayed_payment_basepoint ;
857
845
let counterparty_htlc_base_key = counterparty_channel_parameters. pubkeys . htlc_basepoint ;
858
- let counterparty_tx_cache = CounterpartyCommitmentTransaction { counterparty_delayed_payment_base_key, counterparty_htlc_base_key, on_counterparty_tx_csv, per_htlc : HashMap :: new ( ) } ;
846
+ let counterparty_tx_cache = CounterpartyCommitmentTransaction { counterparty_delayed_payment_base_key, counterparty_htlc_base_key, on_counterparty_tx_csv } ;
859
847
860
848
let channel_keys_id = keys. channel_keys_id ( ) ;
861
849
let holder_revocation_basepoint = keys. pubkeys ( ) . revocation_basepoint ;
@@ -1407,7 +1395,6 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1407
1395
htlcs. push ( htlc. 0 ) ;
1408
1396
}
1409
1397
}
1410
- self . counterparty_tx_cache . per_htlc . insert ( txid, htlcs) ;
1411
1398
}
1412
1399
1413
1400
/// Informs this monitor of the latest holder (ie broadcastable) commitment transaction. The
0 commit comments