@@ -295,19 +295,11 @@ struct CounterpartyCommitmentTransaction {
295
295
counterparty_delayed_payment_base_key : PublicKey ,
296
296
counterparty_htlc_base_key : PublicKey ,
297
297
on_counterparty_tx_csv : u16 ,
298
- per_htlc : HashMap < Txid , Vec < HTLCOutputInCommitment > >
299
298
}
300
299
301
300
impl Writeable for CounterpartyCommitmentTransaction {
302
301
fn write < W : Writer > ( & self , w : & mut W ) -> Result < ( ) , io:: Error > {
303
- w. write_all ( & byte_utils:: be64_to_array ( self . per_htlc . len ( ) as u64 ) ) ?;
304
- for ( ref txid, ref htlcs) in self . per_htlc . iter ( ) {
305
- w. write_all ( & txid[ ..] ) ?;
306
- w. write_all ( & byte_utils:: be64_to_array ( htlcs. len ( ) as u64 ) ) ?;
307
- for & ref htlc in htlcs. iter ( ) {
308
- htlc. write ( w) ?;
309
- }
310
- }
302
+ w. write_all ( & byte_utils:: be64_to_array ( 0 ) ) ?;
311
303
write_tlv_fields ! ( w, {
312
304
( 0 , self . counterparty_delayed_payment_base_key, required) ,
313
305
( 2 , self . counterparty_htlc_base_key, required) ,
@@ -319,20 +311,17 @@ impl Writeable for CounterpartyCommitmentTransaction {
319
311
impl Readable for CounterpartyCommitmentTransaction {
320
312
fn read < R : io:: Read > ( r : & mut R ) -> Result < Self , DecodeError > {
321
313
let counterparty_commitment_transaction = {
314
+ // Versions prior to 0.0.100 had some per-HTLC state stored here, which is no longer
315
+ // used. Read it for compatibility.
322
316
let per_htlc_len: u64 = Readable :: read ( r) ?;
323
- let mut per_htlc = HashMap :: with_capacity ( cmp:: min ( per_htlc_len as usize , MAX_ALLOC_SIZE / 64 ) ) ;
324
317
for _ in 0 ..per_htlc_len {
325
- let txid : Txid = Readable :: read ( r) ?;
318
+ let _txid : Txid = Readable :: read ( r) ?;
326
319
let htlcs_count: u64 = Readable :: read ( r) ?;
327
- let mut htlcs = Vec :: with_capacity ( cmp:: min ( htlcs_count as usize , MAX_ALLOC_SIZE / 32 ) ) ;
328
320
for _ in 0 ..htlcs_count {
329
- let htlc = Readable :: read ( r) ?;
330
- htlcs. push ( htlc) ;
331
- }
332
- if let Some ( _) = per_htlc. insert ( txid, htlcs) {
333
- return Err ( DecodeError :: InvalidValue ) ;
321
+ let _htlc: HTLCOutputInCommitment = Readable :: read ( r) ?;
334
322
}
335
323
}
324
+
336
325
let mut counterparty_delayed_payment_base_key = OptionDeserWrapper ( None ) ;
337
326
let mut counterparty_htlc_base_key = OptionDeserWrapper ( None ) ;
338
327
let mut on_counterparty_tx_csv: u16 = 0 ;
@@ -345,7 +334,6 @@ impl Readable for CounterpartyCommitmentTransaction {
345
334
counterparty_delayed_payment_base_key : counterparty_delayed_payment_base_key. 0 . unwrap ( ) ,
346
335
counterparty_htlc_base_key : counterparty_htlc_base_key. 0 . unwrap ( ) ,
347
336
on_counterparty_tx_csv,
348
- per_htlc,
349
337
}
350
338
} ;
351
339
Ok ( counterparty_commitment_transaction)
@@ -841,7 +829,7 @@ impl<Signer: Sign> ChannelMonitor<Signer> {
841
829
let counterparty_channel_parameters = channel_parameters. counterparty_parameters . as_ref ( ) . unwrap ( ) ;
842
830
let counterparty_delayed_payment_base_key = counterparty_channel_parameters. pubkeys . delayed_payment_basepoint ;
843
831
let counterparty_htlc_base_key = counterparty_channel_parameters. pubkeys . htlc_basepoint ;
844
- let counterparty_tx_cache = CounterpartyCommitmentTransaction { counterparty_delayed_payment_base_key, counterparty_htlc_base_key, on_counterparty_tx_csv, per_htlc : HashMap :: new ( ) } ;
832
+ let counterparty_tx_cache = CounterpartyCommitmentTransaction { counterparty_delayed_payment_base_key, counterparty_htlc_base_key, on_counterparty_tx_csv } ;
845
833
846
834
let channel_keys_id = keys. channel_keys_id ( ) ;
847
835
let holder_revocation_basepoint = keys. pubkeys ( ) . revocation_basepoint ;
@@ -1380,7 +1368,6 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1380
1368
htlcs. push ( htlc. 0 ) ;
1381
1369
}
1382
1370
}
1383
- self . counterparty_tx_cache . per_htlc . insert ( txid, htlcs) ;
1384
1371
}
1385
1372
1386
1373
/// Informs this monitor of the latest holder (ie broadcastable) commitment transaction. The
0 commit comments