@@ -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
} ;
@@ -2393,6 +2399,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2393
2399
}
2394
2400
} ) ;
2395
2401
let entry = OnchainEventEntry {
2402
+ txid : tx. txid ( ) ,
2396
2403
height,
2397
2404
event : OnchainEvent :: HTLCUpdate { htlc_update : ( source, payment_hash) } ,
2398
2405
} ;
@@ -2457,6 +2464,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
2457
2464
}
2458
2465
if let Some ( spendable_output) = spendable_output {
2459
2466
let entry = OnchainEventEntry {
2467
+ txid : tx. txid ( ) ,
2460
2468
height : height,
2461
2469
event : OnchainEvent :: MaturingOutput { descriptor : spendable_output. clone ( ) } ,
2462
2470
} ;
@@ -2729,6 +2737,7 @@ impl<'a, Signer: Sign, K: KeysInterface<Signer = Signer>> ReadableArgs<&'a K>
2729
2737
let waiting_threshold_conf_len: u64 = Readable :: read ( reader) ?;
2730
2738
let mut onchain_events_waiting_threshold_conf = Vec :: with_capacity ( cmp:: min ( waiting_threshold_conf_len as usize , MAX_ALLOC_SIZE / 128 ) ) ;
2731
2739
for _ in 0 ..waiting_threshold_conf_len {
2740
+ let txid = Readable :: read ( reader) ?;
2732
2741
let height = Readable :: read ( reader) ?;
2733
2742
let event = match <u8 as Readable >:: read ( reader) ? {
2734
2743
0 => {
@@ -2746,7 +2755,7 @@ impl<'a, Signer: Sign, K: KeysInterface<Signer = Signer>> ReadableArgs<&'a K>
2746
2755
} ,
2747
2756
_ => return Err ( DecodeError :: InvalidValue ) ,
2748
2757
} ;
2749
- onchain_events_waiting_threshold_conf. push ( OnchainEventEntry { height, event } ) ;
2758
+ onchain_events_waiting_threshold_conf. push ( OnchainEventEntry { txid , height, event } ) ;
2750
2759
}
2751
2760
2752
2761
let outputs_to_watch_len: u64 = Readable :: read ( reader) ?;
0 commit comments