Skip to content

looprpc: preparatory commits for static open channel#1073

Open
hieblmi wants to merge 4 commits intolightninglabs:masterfrom
hieblmi:looprpc-static-open
Open

looprpc: preparatory commits for static open channel#1073
hieblmi wants to merge 4 commits intolightninglabs:masterfrom
hieblmi:looprpc-static-open

Conversation

@hieblmi
Copy link
Collaborator

@hieblmi hieblmi commented Feb 25, 2026

looprpc: prepare for lnrpc usage

In successive commits we want to access lnrpc specifc methods
and objects, so here we import github.com/lightningnetwork/lnd v0.20.1-beta
into looprpc and update relevant versions.

@gemini-code-assist
Copy link

Summary of Changes

Hello @hieblmi, 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 lays the groundwork for enabling static open channel functionality within looprpc. It involves a comprehensive update of the Go development environment and project dependencies to align with the latest lnd version. The core change introduces a new RPC for initiating static channel openings, along with necessary data structures and state tracking mechanisms to manage deposits throughout the channel establishment process. These preparatory steps ensure looprpc can leverage lnrpc's capabilities for future static channel features.

Highlights

  • Go Version Upgrade: The Go language version used across the project's build and development environments has been updated from 1.24 to 1.26.
  • Dependency Updates: Key Go module dependencies, including github.com/lightningnetwork/lnd (to v0.20.1-beta), github.com/lightninglabs/lndclient, and github.com/stretchr/testify, have been upgraded to newer versions.
  • New RPC for Static Channel Opening: A new RPC method, StaticOpenChannel, has been introduced in looprpc to facilitate opening Lightning channels funded by static address deposits.
  • lnrpc Integration: The lnrpc/lightning.proto definitions from lnd are now imported into looprpc/client.proto, allowing reuse of lnrpc.OpenChannelRequest and lnrpc.OutPoint for better interoperability.
  • Deposit State Enhancements: New states, OPENING_CHANNEL and CHANNEL_PUBLISHED, have been added to the DepositState enum, and a value_channels_opened field to StaticAddressSummaryResponse, to track the lifecycle of deposits used for channel openings.

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

Changelog
  • .golangci.yml
    • Updated the required Go version for linting to 1.26.
  • Dockerfile
    • Updated the Go base image to 1.26-alpine.
  • go.mod
    • Upgraded Go version to 1.25.5 and updated various direct and indirect module dependencies, including lnd, lndclient, and testify.
  • go.sum
    • Updated module checksums to reflect dependency upgrades.
  • looprpc/Dockerfile
    • Updated the Go base image to 1.26-bookworm.
  • looprpc/client.proto
    • Imported lnrpc/lightning.proto.
    • Added StaticOpenChannel RPC with its request and response messages.
    • Updated WithdrawDepositsRequest to use lnrpc.OutPoint.
    • Removed the redundant local OutPoint message.
    • Extended StaticAddressSummaryResponse and DepositState with channel opening related fields.
  • looprpc/client.swagger.json
    • Updated the Swagger API documentation to include the new StaticOpenChannel RPC.
    • Removed the looprpc.OutPoint definition.
    • Added new DepositState enum values.
  • looprpc/client_grpc.pb.go
    • Generated Go gRPC client and server interfaces, along with their handlers, for the newly added StaticOpenChannel RPC.
  • looprpc/gen_protos.sh
    • Modified the protobuf generation script to accept an LND_DIR environment variable for including lnrpc proto imports.
  • looprpc/gen_protos_docker.sh
    • Updated the Docker-based protobuf generation script to mount the lnd directory and pass its path as LND_DIR to the container.
  • looprpc/go.mod
    • Updated Go version to 1.25.5 and explicitly added github.com/lightningnetwork/lnd as a direct dependency.
  • looprpc/go.sum
    • Updated module checksums to reflect dependency changes in looprpc/go.mod.
  • release.Dockerfile
    • Updated the Go base image to 1.26.
  • swapserverrpc/go.mod
    • Updated Go version to 1.25.5.
  • tools/Dockerfile
    • Updated the Go base image to 1.26.
  • tools/go.mod
    • Updated Go version to 1.26.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/main.yml
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 prepares the looprpc package for using lnrpc by updating dependencies, Go versions, and build scripts. It also introduces the new StaticOpenChannel RPC and related protobuf messages. The changes are mostly correct and well-structured. My main feedback is about an inconsistency in the Go versions specified across different configuration and module files, which should be aligned to ensure build and linting stability.

version: "2"
run:
go: "1.24"
go: "1.26"

Choose a reason for hiding this comment

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

medium

There's an inconsistency in the Go versions specified across the repository. This file sets Go to 1.26, and so do several Dockerfiles and tools/go.mod. However, the go.mod files in the root, looprpc, and swapserverrpc directories specify go 1.25.5.

For consistency and to avoid potential build or linting issues, it's best to align all these to the same Go version. If the intention is to upgrade to Go 1.26, please update the other go.mod files accordingly (e.g., by running go mod tidy -go=1.26 in each module). Otherwise, this file and others should be aligned to 1.25.

@hieblmi hieblmi self-assigned this Feb 25, 2026
@hieblmi hieblmi force-pushed the looprpc-static-open branch from fa0a1b9 to d88cf08 Compare February 25, 2026 09:01
Copy link
Member

@bhandras bhandras left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

GRPC_GATEWAY_VERSION=$(go list -f '{{.Version}}' -m github.com/grpc-ecosystem/grpc-gateway/v2)

# Get lnd directory from parent go.mod to use the correct version
lnd_dir=$(cd .. && go list -f '{{.Dir}}' -m github.com/lightningnetwork/lnd)
Copy link
Member

Choose a reason for hiding this comment

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

Should we print out lnd_dir? Could help to reassure we're indeed using the right one.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

StaticOpenChannel opens a channel funded by selected static address
deposits.
*/
rpc StaticOpenChannel (StaticOpenChannelRequest)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the commit message is correct, we're extending the proto, not just using this type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good clarification, I fixed the comment.

string address = 2;
}

message OutPoint {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe also mention in the commit message that the replace is safe as the lnrpc types are the same.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good point

Copy link
Collaborator

@starius starius left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀
Left a couple of comments.

syntax = "proto3";

import "swapserverrpc/common.proto";
import "lnrpc/lightning.proto";
Copy link
Collaborator

Choose a reason for hiding this comment

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

I propose to squash commits "looprpc: use lnrpc.OutPoint and lnrpc.OpenChannelRequest" and "loop: use lnrpc.OutPoint instead of looprpc.OutPoint". Otherwise commit "looprpc: use lnrpc.OutPoint and lnrpc.OpenChannelRequest" does not compile.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

looprpc/perms.go Outdated
Comment on lines 139 to 141
"/looprpc.SwapClient/StaticOpenChannel": {{
Entity: "swap",
Action: "execute",
Copy link
Collaborator

Choose a reason for hiding this comment

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

StaticOpenChannel and Withdrawal are not swaps. Do we need swap:execute permission for them? Can we make another permission to spend a deposit?

Copy link
Collaborator Author

@hieblmi hieblmi Feb 26, 2026

Choose a reason for hiding this comment

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

good point. We could use deposit/spend. But unfortunately adding new caveats to existing calls breaks old clients since they need all listed permissions, so they'd have to re-bake their macaroons.

So I'll leave the current permissions untouched, but add a new deposit/spend caveat for the open channel rpc.

defer mgr.Unlock()
return len(mgr.subscribers[NotificationTypeReservation]) > 0
mockClient.Lock()
defer mockClient.Unlock()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add an empty line before return

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

@hieblmi hieblmi force-pushed the looprpc-static-open branch from 9810c52 to faf9b1b Compare February 26, 2026 08:30
In successive commits we want to access lnrpc specifc methods
and objects, so here we import github.com/lightningnetwork/lnd v0.20.1-beta
into looprpc and update relevant versions.
…lRequest

In this commit we import the lnd's lightning.proto into client.proto to
then be able to use lnrpc.OutPoint and lnrpc.OpenChannelRequest instead
of the looprpc.OutPoint type.
This is safe because the lnrpc and looprpc versions of OutPoint are the
same type.
Add macaroon permissions for the new StaticOpenChannel RPC method
and change StaticAddressLoopIn action from read to execute to match
other swap operations.
@hieblmi hieblmi force-pushed the looprpc-static-open branch from faf9b1b to d4c9ab0 Compare February 26, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants