Guest User

Untitled

a guest
Feb 23rd, 2026
17
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.87 KB | None | 0 0
  1. diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs
  2. index 8a7b88859..dd17fe697 100644
  3. --- a/lightning/src/ln/channelmanager.rs
  4. +++ b/lightning/src/ln/channelmanager.rs
  5. @@ -1397,22 +1397,20 @@ pub(crate) enum MonitorUpdateCompletionAction {
  6. /// completes a monitor update containing the payment preimage. In that case, after the inbound
  7. /// edge completes, we will surface an [`Event::PaymentForwarded`] as well as unblock the
  8. /// outbound edge.
  9. - EmitEventOptionAndFreeOtherChannel {
  10. - event: Option<events::Event>,
  11. + EmitEventAndFreeOtherChannel {
  12. + event: events::Event,
  13. downstream_counterparty_and_funding_outpoint: Option<EventUnblockedChannel>,
  14. },
  15. - /// Indicates we should immediately resume the operation of another channel, unless there is
  16. - /// some other reason why the channel is blocked. In practice this simply means immediately
  17. - /// removing the [`RAAMonitorUpdateBlockingAction`] provided from the blocking set.
  18. + /// Indicates we should resume the operation of another channel, unless there is some other
  19. + /// reason why the channel is blocked. In practice this simply means removing the
  20. + /// [`RAAMonitorUpdateBlockingAction`] provided from the blocking set.
  21. ///
  22. /// This is usually generated when we've forwarded an HTLC and want to block the outbound edge
  23. /// from completing a monitor update which removes the payment preimage until the inbound edge
  24. /// completes a monitor update containing the payment preimage. However, we use this variant
  25. - /// instead of [`Self::EmitEventOptionAndFreeOtherChannel`] when we discover that the claim was
  26. - /// in fact duplicative and we simply want to resume the outbound edge channel immediately.
  27. - ///
  28. - /// This variant should thus never be written to disk, as it is processed inline rather than
  29. - /// stored for later processing.
  30. + /// instead of [`Self::EmitEventAndFreeOtherChannel`] when we discover that the claim was
  31. + /// in fact duplicative, or for trampoline payments with multiple incoming HTLCs where we
  32. + /// only want to emit a single event for the entire payment.
  33. FreeOtherChannelImmediately {
  34. downstream_counterparty_node_id: PublicKey,
  35. blocking_action: RAAMonitorUpdateBlockingAction,
  36. @@ -1432,11 +1430,8 @@ impl_writeable_tlv_based_enum_upgradable!(MonitorUpdateCompletionAction,
  37. (4, blocking_action, upgradable_required),
  38. (5, downstream_channel_id, required),
  39. },
  40. - (2, EmitEventOptionAndFreeOtherChannel) => {
  41. - // LDK prior to 0.3 required this field. It will not be present for trampoline payments
  42. - // with multiple incoming HTLCS, so nodes cannot downgrade while trampoline payments
  43. - // are in the process of being resolved.
  44. - (0, event, upgradable_option),
  45. + (2, EmitEventAndFreeOtherChannel) => {
  46. + (0, event, upgradable_required),
  47. // LDK prior to 0.0.116 did not have this field as the monitor update application order was
  48. // required by clients. If we downgrade to something prior to 0.0.116 this may result in
  49. // monitor updates which aren't properly blocked or resumed, however that's fine - we don't
  50. @@ -9259,21 +9254,29 @@ where
  51. } else {
  52. (None, None)
  53. }
  54. - } else {
  55. - let event = make_payment_forwarded_event(htlc_claim_value_msat);
  56. - if let Some(ref payment_forwarded) = event {
  57. - debug_assert!(matches!(
  58. - payment_forwarded,
  59. - &events::Event::PaymentForwarded { .. }
  60. - ));
  61. - }
  62. + } else if let Some(event) = make_payment_forwarded_event(htlc_claim_value_msat) {
  63. + debug_assert!(matches!(
  64. + event,
  65. + events::Event::PaymentForwarded { .. }
  66. + ));
  67. (
  68. - Some(MonitorUpdateCompletionAction::EmitEventOptionAndFreeOtherChannel {
  69. + Some(MonitorUpdateCompletionAction::EmitEventAndFreeOtherChannel {
  70. event,
  71. downstream_counterparty_and_funding_outpoint: chan_to_release,
  72. }),
  73. None,
  74. )
  75. + } else if let Some(chan) = chan_to_release {
  76. + (
  77. + Some(MonitorUpdateCompletionAction::FreeOtherChannelImmediately {
  78. + downstream_counterparty_node_id: chan.counterparty_node_id,
  79. + downstream_channel_id: chan.channel_id,
  80. + blocking_action: chan.blocking_action,
  81. + }),
  82. + None,
  83. + )
  84. + } else {
  85. + (None, None)
  86. }
  87. },
  88. );
  89. @@ -9952,13 +9955,11 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
  90. }
  91. }
  92. },
  93. - MonitorUpdateCompletionAction::EmitEventOptionAndFreeOtherChannel {
  94. + MonitorUpdateCompletionAction::EmitEventAndFreeOtherChannel {
  95. event,
  96. downstream_counterparty_and_funding_outpoint,
  97. } => {
  98. - if let Some(event) = event {
  99. - self.pending_events.lock().unwrap().push_back((event, None));
  100. - }
  101. + self.pending_events.lock().unwrap().push_back((event, None));
  102. if let Some(unblocked) = downstream_counterparty_and_funding_outpoint {
  103. self.handle_monitor_update_release(
  104. unblocked.counterparty_node_id,
  105. @@ -18740,7 +18741,7 @@ where
  106. let logger =
  107. WithContext::from(&args.logger, Some(node_id), Some(*channel_id), None);
  108. for action in actions.iter() {
  109. - if let MonitorUpdateCompletionAction::EmitEventOptionAndFreeOtherChannel {
  110. + if let MonitorUpdateCompletionAction::EmitEventAndFreeOtherChannel {
  111. downstream_counterparty_and_funding_outpoint:
  112. Some(EventUnblockedChannel {
  113. counterparty_node_id: blocked_node_id,
  114. @@ -18770,12 +18771,6 @@ where
  115. // anymore.
  116. }
  117. }
  118. - if let MonitorUpdateCompletionAction::FreeOtherChannelImmediately {
  119. - ..
  120. - } = action
  121. - {
  122. - debug_assert!(false, "Non-event-generating channel freeing should not appear in our queue");
  123. - }
  124. }
  125. // Note that we may have a post-update action for a channel that has no pending
  126. // `ChannelMonitorUpdate`s, but unlike the no-peer-state case, it may simply be
  127.  
Advertisement
Add Comment
Please, Sign In to add comment