Skip to content

[WIP] Add change address to SendCoinsRequest (#10271)#10769

Open
code-orange-dev wants to merge 4 commits intolightningnetwork:masterfrom
code-orange-dev:fix/10271-sendcoins-change-addr
Open

[WIP] Add change address to SendCoinsRequest (#10271)#10769
code-orange-dev wants to merge 4 commits intolightningnetwork:masterfrom
code-orange-dev:fix/10271-sendcoins-change-addr

Conversation

@code-orange-dev
Copy link
Copy Markdown

Work in Progress

This PR adds change_address support to SendCoinsRequest.

TODO

  • Update protobuf definitions
  • Regenerate Go code
  • Update lncli
  • Implement wallet logic
  • Add tests

See CHANGE-10271.md for implementation guide.

Relates-to: #10271


🍊 Contributed via Code Orange Dev School

Add change_address field to SendCoinsRequest.

Relates-to: lightningnetwork#10271
@github-actions github-actions Bot added the severity-low Best-effort review label Apr 26, 2026
@github-actions
Copy link
Copy Markdown

PR Severity: LOW

Automated classification | 1 file | 31 lines changed

Low (1 file):

  • CHANGE-10271.md - Markdown changelog/release-notes file

Analysis

This PR adds a single markdown changelog file (CHANGE-10271.md). Markdown documentation and release-note files fall into the LOW severity tier, as they require no code review of critical subsystems. No severity bump conditions apply: only 1 non-test/non-generated file is touched, and 31 lines changed (well below the 500-line threshold).


To override, add a severity-override-{critical,high,medium,low} label.
<!-- pr-severity-bot -->

@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 introduces the initial planning and documentation for adding a custom change address option to the SendCoinsRequest functionality. It serves as a roadmap for upcoming changes to the RPC definitions, CLI commands, and wallet logic.

Highlights

  • Implementation Guide: Added a new documentation file, CHANGE-10271.md, outlining the necessary steps to implement the change address feature in SendCoinsRequest.

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

Add --change_addr flag to lncli sendcoins command, allowing users
to specify a custom change address instead of using the wallet's
internal change output.

Changes:
- Add change_addr flag to sendcoins CLI command
- Add ChangeAddr field to SendCoinsRequest proto
- Pass change address to SendCoins RPC call

Fixes lightningnetwork#10271

🍊 Code Orange Dev School contribution
@github-actions github-actions Bot added severity-medium Focused review required and removed severity-low Best-effort review labels Apr 26, 2026
@github-actions
Copy link
Copy Markdown

⚠️ Severity changed: LOWMEDIUM (files changed since last classification)

🟡 PR Severity: MEDIUM

Bot classification | 3 files | 42 lines changed

🟡 Medium (2 files)
  • cmd/commands/commands.go - CLI client command changes (cmd/* is always MEDIUM)
  • lnrpc/lightning.proto - Proto/API definition change
🟢 Low (1 file)
  • CHANGE-10271.md - Markdown/documentation file

Analysis

The overall severity is MEDIUM, driven by two files:

  • cmd/commands/commands.go lives under cmd/* (CLI client code) which is always classified as MEDIUM regardless of any server-side package names in the path.
  • lnrpc/lightning.proto is a .proto file representing an API change, which falls under MEDIUM.

No severity bump applies: only 3 non-test/non-generated files changed (threshold: 20) and 42 lines changed (threshold: 500). No multiple distinct critical packages are touched.


To override, add a severity-override-{critical,high,medium,low} label.
<!-- pr-severity-bot -->

Add basic unit test to verify SendCoinsRequest properly
handles the ChangeAddr field.

Part of lightningnetwork#10271
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 an implementation guide for adding custom change address support to the SendCoins RPC. The reviewer provided several constructive suggestions to improve the guide, including extending support to the SendManyRequest RPC, correcting protobuf field numbering and documentation, and fixing inaccuracies regarding file paths and method names in the wallet logic.

Comment thread CHANGE-10271.md

## Changes Needed

### 1. lnrpc/lightning.proto
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

While the PR focuses on SendCoinsRequest, it would be beneficial to also add change_address support to SendManyRequest for completeness, as both RPCs involve creating on-chain transactions where a custom change address might be desired.

Comment thread CHANGE-10271.md
### 1. lnrpc/lightning.proto
Add to `SendCoinsRequest`:
```protobuf
string change_address = 15;
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 proposed protobuf field definition has two issues:

  1. Field Number Gap: The last field in SendCoinsRequest is 11. Using 15 creates an unnecessary gap. It is recommended to use the next available number, 12, to maintain sequential ordering.
  2. Missing Documentation: Per the instructions at the top of lightning.proto (lines 8-11), all fields should have a documentation comment as they are parsed into the API documentation.
Suggested change
string change_address = 15;
// The optional address to send the change to.
string change_address = 12;

Comment thread CHANGE-10271.md
},
```

### 3. lnd/lnwallet/btcwallet/btcwallet.go
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 file path lnd/lnwallet/btcwallet/btcwallet.go contains an unnecessary lnd/ prefix. Based on the repository structure provided in the context, the correct path is lnwallet/btcwallet/btcwallet.go.

Suggested change
### 3. lnd/lnwallet/btcwallet/btcwallet.go
### 3. lnwallet/btcwallet/btcwallet.go

Comment thread CHANGE-10271.md
```

### 3. lnd/lnwallet/btcwallet/btcwallet.go
Update `SendCoins` to use change address.
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 BtcWallet struct in lnwallet/btcwallet/btcwallet.go does not have a SendCoins method. The logic for creating and sending on-chain transactions is handled by the SendOutputs method. The guide should be updated to reflect the correct method name to avoid confusion during implementation.

Suggested change
Update `SendCoins` to use change address.
Update `SendOutputs` to use change address.

@github-actions github-actions Bot added severity-medium Focused review required and removed severity-medium Focused review required labels Apr 26, 2026
Add testSendCoinsWithChangeAddr to verify the change_addr feature
works correctly in an integration test environment.

The test:
- Creates destination and change addresses
- Sends coins with custom change address
- Verifies change output goes to specified address
- Confirms transaction is mined successfully

Part of lightningnetwork#10271
@lightninglabs-deploy
Copy link
Copy Markdown
Collaborator

@code-orange-dev, remember to re-request review from reviewers when ready

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

Labels

severity-medium Focused review required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants