@@ -465,11 +465,13 @@ pub(crate) struct ClaimRequest {
465
465
pub ( crate ) witness_data : InputMaterial
466
466
}
467
467
468
- /// An entry for an [`OnchainEvent`], stating the block height when the event was observed.
468
+ /// An entry for an [`OnchainEvent`], stating the block height when the event was observed and the
469
+ /// transaction causing it.
469
470
///
470
471
/// Used to determine when the on-chain event can be considered safe from a chain reorganization.
471
472
#[ derive( PartialEq ) ]
472
473
struct OnchainEventEntry {
474
+ txid : Txid ,
473
475
height : u32 ,
474
476
event : OnchainEvent ,
475
477
}
@@ -956,6 +958,7 @@ impl<Signer: Sign> Writeable for ChannelMonitorImpl<Signer> {
956
958
957
959
writer. write_all ( & byte_utils:: be64_to_array ( self . onchain_events_waiting_threshold_conf . len ( ) as u64 ) ) ?;
958
960
for ref entry in self . onchain_events_waiting_threshold_conf . iter ( ) {
961
+ entry. txid . write ( writer) ?;
959
962
writer. write_all ( & byte_utils:: be32_to_array ( entry. height ) ) ?;
960
963
match entry. event {
961
964
OnchainEvent :: HTLCUpdate { ref htlc_update } => {
@@ -1667,6 +1670,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1667
1670
}
1668
1671
} ) ;
1669
1672
let entry = OnchainEventEntry {
1673
+ txid: * $txid,
1670
1674
height,
1671
1675
event: OnchainEvent :: HTLCUpdate {
1672
1676
htlc_update: ( ( * * source) . clone( ) , htlc. payment_hash. clone( ) )
@@ -1732,6 +1736,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1732
1736
}
1733
1737
} ) ;
1734
1738
self . onchain_events_waiting_threshold_conf. push( OnchainEventEntry {
1739
+ txid: * $txid,
1735
1740
height,
1736
1741
event: OnchainEvent :: HTLCUpdate {
1737
1742
htlc_update: ( ( * * source) . clone( ) , htlc. payment_hash. clone( ) )
@@ -1887,6 +1892,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1887
1892
}
1888
1893
} ) ;
1889
1894
let entry = OnchainEventEntry {
1895
+ txid: commitment_txid,
1890
1896
height,
1891
1897
event: OnchainEvent :: HTLCUpdate { htlc_update: ( $source, $payment_hash) } ,
1892
1898
} ;
@@ -2395,6 +2401,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2395
2401
}
2396
2402
} ) ;
2397
2403
let entry = OnchainEventEntry {
2404
+ txid : tx. txid ( ) ,
2398
2405
height,
2399
2406
event : OnchainEvent :: HTLCUpdate { htlc_update : ( source, payment_hash) } ,
2400
2407
} ;
@@ -2459,6 +2466,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2459
2466
}
2460
2467
if let Some ( spendable_output) = spendable_output {
2461
2468
let entry = OnchainEventEntry {
2469
+ txid : tx. txid ( ) ,
2462
2470
height : height,
2463
2471
event : OnchainEvent :: MaturingOutput { descriptor : spendable_output. clone ( ) } ,
2464
2472
} ;
@@ -2731,6 +2739,7 @@ impl<'a, Signer: Sign, K: KeysInterface<Signer = Signer>> ReadableArgs<&'a K>
2731
2739
let waiting_threshold_conf_len: u64 = Readable :: read ( reader) ?;
2732
2740
let mut onchain_events_waiting_threshold_conf = Vec :: with_capacity ( cmp:: min ( waiting_threshold_conf_len as usize , MAX_ALLOC_SIZE / 128 ) ) ;
2733
2741
for _ in 0 ..waiting_threshold_conf_len {
2742
+ let txid = Readable :: read ( reader) ?;
2734
2743
let height = Readable :: read ( reader) ?;
2735
2744
let event = match <u8 as Readable >:: read ( reader) ? {
2736
2745
0 => {
@@ -2748,7 +2757,7 @@ impl<'a, Signer: Sign, K: KeysInterface<Signer = Signer>> ReadableArgs<&'a K>
2748
2757
} ,
2749
2758
_ => return Err ( DecodeError :: InvalidValue ) ,
2750
2759
} ;
2751
- onchain_events_waiting_threshold_conf. push ( OnchainEventEntry { height, event } ) ;
2760
+ onchain_events_waiting_threshold_conf. push ( OnchainEventEntry { txid , height, event } ) ;
2752
2761
}
2753
2762
2754
2763
let outputs_to_watch_len: u64 = Readable :: read ( reader) ?;
0 commit comments