Skip to content

Commit 13c5908

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 86a23fe commit 13c5908

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
@@ -1485,6 +1485,17 @@ pub(crate) enum MonitorUpdateCompletionAction {
14851485
/// to avoid acking a monitor event until after an HTLC is fully removed via revoke_and_ack, to
14861486
/// ensure that the HTLC gets resolved even if we lose the holding cell.
14871487
AckMonitorEvents { event_ids: Vec<MonitorEventSource> },
1488+
/// Indicates we should emit an [`Event::PaymentForwarded`] and possibly ack a monitor event via
1489+
/// [`Watch::ack_monitor_event`].
1490+
///
1491+
/// This is generated when we've completed an inbound edge preimage update for an HTLC forward,
1492+
/// at which point it's safe to generate the forward event. If the inbound edge is closed, a
1493+
/// monitor event id may be included so we can tell the outbound edge to stop telling us about
1494+
/// the claim once the forward event is processed by the user.
1495+
EmitForwardEvent {
1496+
event: ForwardEventContents,
1497+
post_event_ackable_monitor_event: Option<MonitorEventSource>,
1498+
},
14881499
}
14891500

14901501
impl_writeable_tlv_based_enum_upgradable!(MonitorUpdateCompletionAction,
@@ -1508,6 +1519,10 @@ impl_writeable_tlv_based_enum_upgradable!(MonitorUpdateCompletionAction,
15081519
},
15091520
(3, AckMonitorEvents) => {
15101521
(1, event_ids, required_vec),
1522+
},
1523+
(5, EmitForwardEvent) => {
1524+
(1, event, required),
1525+
(3, post_event_ackable_monitor_event, option),
15111526
}
15121527
);
15131528

@@ -10491,6 +10506,17 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1049110506
self.chain_monitor.ack_monitor_event(id);
1049210507
}
1049310508
},
10509+
MonitorUpdateCompletionAction::EmitForwardEvent {
10510+
event,
10511+
post_event_ackable_monitor_event,
10512+
} => {
10513+
let post_event_action = post_event_ackable_monitor_event
10514+
.map(|event_id| EventCompletionAction::AckMonitorEvent { event_id });
10515+
self.pending_events
10516+
.lock()
10517+
.unwrap()
10518+
.push_back((event.into(), post_event_action));
10519+
},
1049410520
}
1049510521
}
1049610522

0 commit comments

Comments
 (0)