Skip to content

Commit bcb7155

Browse files
Add MonitorUpdateCompletionAction::EmitForwardEvent
Indicates we should emit an Event::PaymentForwarded and possibly ack a monitor event via Watch::ack_monitor_event. This is generated when we've completed an inbound edge preimage update for an HTLC forward, at which point it's safe to generate the forward event. If the inbound edge is closed, a monitor event id may be included so we can tell the outbound edge to stop telling us about the claim once the forward event is processed by the user.
1 parent 9c84c30 commit bcb7155

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

lightning/src/ln/channelmanager.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,6 +1570,17 @@ pub(crate) enum MonitorUpdateCompletionAction {
15701570
/// persisted in the inbound edge monitor, but if we stop persisting the holding cell in the
15711571
/// future then that approach could cause us to forget to claim upstream via update_fulfill.
15721572
AckMonitorEvents { event_ids: Vec<MonitorEventSource> },
1573+
/// Indicates we should emit an [`Event::PaymentForwarded`] and possibly ack a monitor event via
1574+
/// [`Watch::ack_monitor_event`].
1575+
///
1576+
/// This is generated when we've completed an inbound edge preimage update for an HTLC forward,
1577+
/// at which point it's safe to generate the forward event. If the inbound edge is closed, a
1578+
/// monitor event id may be included so we can tell the outbound edge to stop telling us about
1579+
/// the claim once the forward event is processed by the user.
1580+
EmitForwardEvent {
1581+
event: ForwardEventContents,
1582+
post_event_ackable_monitor_event: Option<MonitorEventSource>,
1583+
},
15731584
}
15741585

15751586
impl_writeable_tlv_based_enum_upgradable!(MonitorUpdateCompletionAction,
@@ -1593,6 +1604,10 @@ impl_writeable_tlv_based_enum_upgradable!(MonitorUpdateCompletionAction,
15931604
},
15941605
(3, AckMonitorEvents) => {
15951606
(1, event_ids, required_vec),
1607+
},
1608+
(5, EmitForwardEvent) => {
1609+
(1, event, required),
1610+
(3, post_event_ackable_monitor_event, option),
15961611
}
15971612
);
15981613

@@ -10659,6 +10674,17 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1065910674
self.chain_monitor.ack_monitor_event(id);
1066010675
}
1066110676
},
10677+
MonitorUpdateCompletionAction::EmitForwardEvent {
10678+
event,
10679+
post_event_ackable_monitor_event,
10680+
} => {
10681+
let post_event_action = post_event_ackable_monitor_event
10682+
.map(|event_id| EventCompletionAction::AckMonitorEvent { event_id });
10683+
self.pending_events
10684+
.lock()
10685+
.unwrap()
10686+
.push_back((event.into(), post_event_action));
10687+
},
1066210688
}
1066310689
}
1066410690

0 commit comments

Comments
 (0)