Skip to content

Conversation

@starius
Copy link
Collaborator

@starius starius commented Jan 15, 2026

Add loopd RPC SweepHtlc and CLI command loop out sweephtlc:

$ loop out sweephtlc -h
NAME:
   loop out sweephtlc - sweep an HTLC output using the preimage success path

USAGE:
   loop out sweephtlc [options]

OPTIONS:
   --outpoint string  htlc outpoint to sweep (format: txid:vout)
   --htlcaddr string  htlc address corresponding to the outpoint
   --feerate uint     fee rate to use in sat/vbyte
   --destaddr string  optional destination address; defaults to a new wallet address
   --preimage string  optional preimage hex to override stored swap preimage
   --publish          publish the sweep transaction immediately (default: false)

Pull Request Checklist

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

@gemini-code-assist
Copy link

Summary of Changes

Hello @starius, 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 enhances the loop client by introducing a new command that allows for the manual sweeping of loop-out HTLCs. This feature empowers users with direct control over their funds, enabling them to recover HTLCs using a known preimage. Concurrently, the PR refactors and centralizes the fee calculation and clamping mechanisms for sweep transactions, ensuring that all on-chain transactions are economically sound and adhere to network relay policies.

Highlights

  • New Manual HTLC Sweep Command: Introduced a new RPC SweepHtlc and a corresponding CLI command loop out sweephtlc to allow users to manually sweep loop-out HTLCs using a known preimage. This provides greater control over funds in scenarios where automatic sweeping might be delayed or fail.
  • Centralized Fee Clamping Logic: Refactored fee calculation and validation logic into a new utility function utils.ClampSweepFee. This function ensures that sweep transaction fees do not exceed a certain percentage of the HTLC value and also respects the minimum relay fee, preventing uneconomical or invalid transactions.
  • Comprehensive Testing: Added extensive table tests for the new sweepHtlc functionality, covering various success and error conditions, including fee clamping and publishing outcomes.
  • API and Documentation Updates: Updated gRPC API definitions, gRPC gateway, Swagger documentation, and CLI man pages to reflect the new SweepHtlc RPC and command, ensuring proper integration and user guidance.

🧠 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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

@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 new sweephtlc command to manually sweep a loop-out HTLC, along with the corresponding SweepHtlc RPC. The implementation is well-structured, with clear separation of concerns and good test coverage for the new functionality. A notable improvement is the refactoring of fee clamping logic into a shared utility function, which is now used across different parts of the codebase, enhancing consistency and maintainability. My review includes a suggestion to improve the performance of swap lookups, a fix for minor comment typos in the protobuf definition, and a recommendation to enhance test coverage for the new fee utility.

The command is hidden, it is not for everyday use.
@starius starius marked this pull request as ready for review January 15, 2026 08:52
@starius starius requested a review from alexbosworth January 15, 2026 15:07
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.

2 participants