@@ -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
}
@@ -954,6 +956,7 @@ impl<Signer: Sign> Writeable for ChannelMonitorImpl<Signer> {
954
956
955
957
writer. write_all ( & byte_utils:: be64_to_array ( self . onchain_events_waiting_threshold_conf . len ( ) as u64 ) ) ?;
956
958
for ref entry in self . onchain_events_waiting_threshold_conf . iter ( ) {
959
+ entry. txid . write ( writer) ?;
957
960
writer. write_all ( & byte_utils:: be32_to_array ( entry. height ) ) ?;
958
961
match entry. event {
959
962
OnchainEvent :: HTLCUpdate { ref htlc_update } => {
@@ -1665,6 +1668,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1665
1668
}
1666
1669
} ) ;
1667
1670
let entry = OnchainEventEntry {
1671
+ txid: * $txid,
1668
1672
height,
1669
1673
event: OnchainEvent :: HTLCUpdate {
1670
1674
htlc_update: ( ( * * source) . clone( ) , htlc. payment_hash. clone( ) )
@@ -1730,6 +1734,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1730
1734
}
1731
1735
} ) ;
1732
1736
self . onchain_events_waiting_threshold_conf. push( OnchainEventEntry {
1737
+ txid: * $txid,
1733
1738
height,
1734
1739
event: OnchainEvent :: HTLCUpdate {
1735
1740
htlc_update: ( ( * * source) . clone( ) , htlc. payment_hash. clone( ) )
@@ -1885,6 +1890,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
1885
1890
}
1886
1891
} ) ;
1887
1892
let entry = OnchainEventEntry {
1893
+ txid: commitment_txid,
1888
1894
height,
1889
1895
event: OnchainEvent :: HTLCUpdate { htlc_update: ( $source, $payment_hash) } ,
1890
1896
} ;
@@ -2403,6 +2409,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2403
2409
}
2404
2410
} ) ;
2405
2411
let entry = OnchainEventEntry {
2412
+ txid : tx. txid ( ) ,
2406
2413
height,
2407
2414
event : OnchainEvent :: HTLCUpdate { htlc_update : ( source, payment_hash) } ,
2408
2415
} ;
@@ -2467,6 +2474,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2467
2474
}
2468
2475
if let Some ( spendable_output) = spendable_output {
2469
2476
let entry = OnchainEventEntry {
2477
+ txid : tx. txid ( ) ,
2470
2478
height : height,
2471
2479
event : OnchainEvent :: MaturingOutput { descriptor : spendable_output. clone ( ) } ,
2472
2480
} ;
@@ -2739,6 +2747,7 @@ impl<'a, Signer: Sign, K: KeysInterface<Signer = Signer>> ReadableArgs<&'a K>
2739
2747
let waiting_threshold_conf_len: u64 = Readable :: read ( reader) ?;
2740
2748
let mut onchain_events_waiting_threshold_conf = Vec :: with_capacity ( cmp:: min ( waiting_threshold_conf_len as usize , MAX_ALLOC_SIZE / 128 ) ) ;
2741
2749
for _ in 0 ..waiting_threshold_conf_len {
2750
+ let txid = Readable :: read ( reader) ?;
2742
2751
let height = Readable :: read ( reader) ?;
2743
2752
let event = match <u8 as Readable >:: read ( reader) ? {
2744
2753
0 => {
@@ -2756,7 +2765,7 @@ impl<'a, Signer: Sign, K: KeysInterface<Signer = Signer>> ReadableArgs<&'a K>
2756
2765
} ,
2757
2766
_ => return Err ( DecodeError :: InvalidValue ) ,
2758
2767
} ;
2759
- onchain_events_waiting_threshold_conf. push ( OnchainEventEntry { height, event } ) ;
2768
+ onchain_events_waiting_threshold_conf. push ( OnchainEventEntry { txid , height, event } ) ;
2760
2769
}
2761
2770
2762
2771
let outputs_to_watch_len: u64 = Readable :: read ( reader) ?;
0 commit comments