@@ -635,6 +635,9 @@ impl_writeable_tlv_based_enum_upgradable!(OnchainEvent,
635635
636636#[ derive( Clone , Debug , PartialEq , Eq ) ]
637637pub ( crate ) enum ChannelMonitorUpdateStep {
638+ EventGenerated {
639+ event : Event ,
640+ } ,
638641 LatestHolderCommitmentTXInfo {
639642 commitment_tx : HolderCommitmentTransaction ,
640643 /// Note that LDK after 0.0.115 supports this only containing dust HTLCs (implying the
@@ -724,6 +727,7 @@ impl ChannelMonitorUpdateStep {
724727 ChannelMonitorUpdateStep :: RenegotiatedFunding { .. } => "RenegotiatedFunding" ,
725728 ChannelMonitorUpdateStep :: RenegotiatedFundingLocked { .. } => "RenegotiatedFundingLocked" ,
726729 ChannelMonitorUpdateStep :: ReleasePaymentComplete { .. } => "ReleasePaymentComplete" ,
730+ ChannelMonitorUpdateStep :: EventGenerated { .. } => "EventGenerated" ,
727731 }
728732 }
729733}
@@ -778,6 +782,9 @@ impl_writeable_tlv_based_enum_upgradable!(ChannelMonitorUpdateStep,
778782 ( 12 , RenegotiatedFundingLocked ) => {
779783 ( 1 , funding_txid, required) ,
780784 } ,
785+ ( 13 , EventGenerated ) => {
786+ ( 0 , event, upgradable_required) ,
787+ }
781788) ;
782789
783790/// Indicates whether the balance is derived from a cooperative close, a force-close
@@ -1283,6 +1290,7 @@ pub(crate) struct ChannelMonitorImpl<Signer: EcdsaChannelSigner> {
12831290 pending_monitor_events : Vec < MonitorEvent > ,
12841291
12851292 pub ( super ) pending_events : Vec < Event > ,
1293+ pub ( super ) pending_mgr_events : Vec < Event > ,
12861294 pub ( super ) is_processing_pending_events : bool ,
12871295
12881296 // Used to track on-chain events (i.e., transactions part of channels confirmed on chain) on
@@ -1961,6 +1969,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitor<Signer> {
19611969
19621970 payment_preimages : new_hash_map ( ) ,
19631971 pending_monitor_events : Vec :: new ( ) ,
1972+ pending_mgr_events : Vec :: new ( ) ,
19641973 pending_events : Vec :: new ( ) ,
19651974 is_processing_pending_events : false ,
19661975
@@ -4370,6 +4379,10 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
43704379 log_trace ! ( logger, "HTLC {htlc:?} permanently and fully resolved" ) ;
43714380 self . htlcs_resolved_to_user . insert ( * htlc) ;
43724381 } ,
4382+ ChannelMonitorUpdateStep :: EventGenerated { event } => {
4383+ log_trace ! ( logger, "Updating ChannelMonitor with channel manager event: {:?}" , event) ;
4384+ self . pending_mgr_events . push ( event. clone ( ) ) ;
4385+ } ,
43734386 }
43744387 }
43754388
@@ -4402,6 +4415,7 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
44024415 ChannelMonitorUpdateStep :: PaymentPreimage { .. } => { } ,
44034416 ChannelMonitorUpdateStep :: ChannelForceClosed { .. } => { } ,
44044417 ChannelMonitorUpdateStep :: ReleasePaymentComplete { .. } => { } ,
4418+ ChannelMonitorUpdateStep :: EventGenerated { .. } => { } ,
44054419 }
44064420 }
44074421
@@ -6644,6 +6658,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
66446658 let mut alternative_funding_confirmed = None ;
66456659 let mut is_manual_broadcast = RequiredWrapper ( None ) ;
66466660 let mut funding_seen_onchain = RequiredWrapper ( None ) ;
6661+ let mut pending_mgr_events = Some ( Vec :: new ( ) ) ;
66476662 read_tlv_fields ! ( reader, {
66486663 ( 1 , funding_spend_confirmed, option) ,
66496664 ( 3 , htlcs_resolved_on_chain, optional_vec) ,
@@ -6666,6 +6681,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
66666681 ( 34 , alternative_funding_confirmed, option) ,
66676682 ( 35 , is_manual_broadcast, ( default_value, false ) ) ,
66686683 ( 37 , funding_seen_onchain, ( default_value, true ) ) ,
6684+ ( 38 , pending_mgr_events, optional_vec) ,
66696685 } ) ;
66706686 // Note that `payment_preimages_with_info` was added (and is always written) in LDK 0.1, so
66716687 // we can use it to determine if this monitor was last written by LDK 0.1 or later.
@@ -6812,6 +6828,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP
68126828
68136829 payment_preimages,
68146830 pending_monitor_events : pending_monitor_events. unwrap ( ) ,
6831+ pending_mgr_events : pending_mgr_events. unwrap ( ) ,
68156832 pending_events,
68166833 is_processing_pending_events : false ,
68176834
0 commit comments