Skip to content

loopout: handle htlc confirmed notification#1120

Draft
starius wants to merge 5 commits intolightninglabs:masterfrom
starius:htlc-notification2
Draft

loopout: handle htlc confirmed notification#1120
starius wants to merge 5 commits intolightninglabs:masterfrom
starius:htlc-notification2

Conversation

@starius
Copy link
Copy Markdown
Collaborator

@starius starius commented Apr 14, 2026

Add a parallel HTLC-confirmed notification path in waitForConfirmedHtlc that competes with the existing chain notifier path.

Add swap-scoped deduplication for retry notifications and validate outpoint index plus pkscript before accepting notification-based confirmation.

Update unit tests to cover success, invalid inputs, output mismatch, cancellation, nil notifier, and deduplication behavior.

Pull Request Checklist

  • Update release_notes.md if your PR contains major features, breaking changes or bugfixes

starius added 5 commits April 14, 2026 03:58
Add ServerHtlcConfirmedNotification message to SubscribeNotificationsResponse
oneof. This new notification type allows the server to inform the client that
a loop out HTLC has been confirmed on-chain, including the confirmed outpoint.
Add NotificationTypeHtlcConfirmed and SubscribeHtlcConfirmed so consumers
can subscribe to HTLC-confirmed notifications. Also add dispatch in
handleNotification to forward htlc_confirmed messages to subscribers.
Log unknown server notification variants at Info level instead of Warn
to avoid noisy logs during feature rollout mismatches.
Add a parallel HTLC-confirmed notification path in waitForConfirmedHtlc that
competes with the existing chain notifier path.

Add swap-scoped deduplication for retry notifications and validate outpoint
index plus pkscript before accepting notification-based confirmation.

Update unit tests to cover success, invalid inputs, output mismatch,
cancellation, nil notifier, and deduplication behavior.
Wire the notification manager as the HTLC confirmed notifier through the client
config to swapConfig so that individual loop out swaps can subscribe to
server-side HTLC confirmed notifications.
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the reliability and responsiveness of HTLC confirmation in Loop by introducing an alternative, server-driven notification mechanism. This new path runs in parallel with the existing chain-based confirmation, aiming to accelerate the detection of confirmed HTLCs. It also incorporates sophisticated deduplication and validation logic to ensure the integrity and efficiency of these notifications, making the system more resilient to network conditions and server retries.

Highlights

  • Parallel HTLC Confirmation Path: Implemented a parallel notification path for HTLC confirmations, allowing server-side notifications to compete with the existing chain notifier for faster confirmation detection.
  • Swap-Scoped Deduplication and Validation: Introduced swap-scoped deduplication for HTLC confirmation retry notifications to prevent redundant processing and added robust validation for HTLC outpoint index and public key script before accepting notification-based confirmations.
  • Expanded Unit Test Coverage: Expanded unit test coverage for HTLC confirmation handling, including success cases, invalid inputs, output mismatches, cancellation, nil notifiers, and deduplication logic.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a mechanism for loop out swaps to receive HTLC confirmation notifications from the server. It adds a new HtlcConfirmedNotifier interface, updates the notification manager to handle HtlcConfirmed notifications, and implements a parallel listener in loopOutSwap that registers for on-chain confirmations upon receiving a server notification. The implementation includes an atomic state machine to handle retries and deduplication. Feedback was provided regarding the log level for unknown notification types, suggesting a change from Infof to Debugf to minimize log noise during normal operation.

Comment on lines +388 to 389
log.Infof("Received unknown notification type: %v",
ntfn)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The log level for unknown notification types has been changed from Warnf to Infof. While this is a reasonable change to avoid spamming warnings for new, unsupported notification types, it might be better to use Debugf. An unknown notification type is not something that requires operator attention at an Info level, but it is useful for debugging. Using Debugf would keep the logs cleaner for normal operation while still providing the necessary information when debugging.

Suggested change
log.Infof("Received unknown notification type: %v",
ntfn)
log.Debugf("Received unknown notification type: %v",
ntfn)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant