Skip to content

Conversation

@federicociro
Copy link

Change Description

This PR adds an optional include_raw_tx field to BumpFeeRequest and a corresponding raw_tx field to BumpFeeResponse. When include_raw_tx is set to true, the RPC will
wait for the sweep transaction to be created and return its hex-encoded raw transaction in the response.

This addresses issue #8470, allowing users to manually broadcast transactions in cases where they don't propagate automatically through the network.

Changes Made:

  • Add include_raw_tx bool field to BumpFeeRequest proto (lnrpc/walletrpc/walletkit.proto:3145)
  • Add raw_tx string field to BumpFeeResponse proto (lnrpc/walletrpc/walletkit.proto:3255)
  • Modify BumpFee implementation to optionally wait for sweep result (lnrpc/walletrpc/walletkit_server.go:1157)
  • Update sweepNewInput to return result channel for transaction tracking (lnrpc/walletrpc/walletkit_server.go:1292)
  • Add --include_raw_tx flag to lncli wallet bumpfee command (cmd/commands/walletrpc_active.go:319)
  • Regenerate protobuf definitions and gRPC stubs

Closes #8470

Steps to Test

Prerequisites:

  • Build debug binaries: make build
  • Have a pending sweep transaction (can be created via anchor channel closing or CPFP bumping)

Testing the new functionality:

  1. Test with include_raw_tx flag:
    ./lncli-debug wallet bumpfee --outpoint <txid>:<index> \
      --sat_per_vbyte 10 \
      --include_raw_tx
    Verify that the response includes the raw_tx field with hex-encoded transaction data.
    
  2. Test without include_raw_tx flag (backward compatibility):
    ./lncli-debug wallet bumpfee --outpoint :
    --sat_per_vbyte 10
  3. Verify that the response returns immediately with status only (no raw_tx field).
  4. Test via gRPC:
    Use the gRPC API directly with include_raw_tx: true and verify the response contains the raw transaction.
  5. Verify transaction broadcast:
    Use the returned raw transaction hex to manually broadcast via:
    bitcoin-cli sendrawtransaction <raw_tx_hex>

Expected behavior:

  • When include_raw_tx=false (or omitted): Response returns immediately with status
  • When include_raw_tx=true: Response waits for sweep tx creation and includes raw transaction hex
  • Backward compatibility: Existing calls without the flag continue to work as before

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

📝 Please see our Contribution Guidelines for further guidance.

This commit adds an optional include_raw_tx field to BumpFeeRequest
and a raw_tx field to BumpFeeResponse. When include_raw_tx is set to
true, the RPC will wait for the sweep transaction to be created and
return its hex-encoded raw transaction.

This allows users to manually broadcast transactions in cases where
they don't propagate automatically, addressing issue lightningnetwork#8470.

Changes:
- Add include_raw_tx bool field to BumpFeeRequest proto
- Add raw_tx string field to BumpFeeResponse proto
- Modify BumpFee implementation to optionally wait for sweep result
- Update sweepNewInput to return result channel
- Add --include_raw_tx flag to lncli wallet bumpfee command

Closes lightningnetwork#8470
@gemini-code-assist
Copy link

Summary of Changes

Hello @federicociro, 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 a significant enhancement to the BumpFee RPC functionality, allowing for greater control over transaction broadcasting. By adding an optional parameter to request the raw, hex-encoded sweep transaction, it provides a crucial fallback mechanism for users encountering network propagation issues. This change directly addresses a known problem by empowering users to manually broadcast their fee-bumped transactions, ensuring their timely inclusion on the blockchain.

Highlights

  • RPC Enhancement: The BumpFee RPC now supports an optional include_raw_tx field in its request and returns a raw_tx field in its response.
  • Manual Broadcast Support: Users can now retrieve the hex-encoded raw sweep transaction, enabling manual broadcasting in cases where transactions do not propagate automatically through the network.
  • CLI Integration: The lncli wallet bumpfee command has been updated with a new --include_raw_tx flag to expose this functionality to command-line users.
  • Protobuf Updates: The walletkit.proto definition and its generated Go files (walletkit.pb.go, walletkit.swagger.json) have been updated to include the new include_raw_tx and raw_tx fields.
  • Sweeper Logic Refinement: The internal BumpFee and sweepNewInput functions were modified to handle the optional raw transaction retrieval, including waiting for the sweep result before returning the response.
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 valuable feature by adding an optional include_raw_tx field to the BumpFee RPC call, allowing users to retrieve the raw transaction hex. The implementation is solid, correctly handling the asynchronous nature of sweep transaction creation using a result channel. My review includes a couple of suggestions to improve code style and documentation for better clarity and maintainability.

Comment on lines +1196 to +1197
return nil, fmt.Errorf("failed to "+
"serialize tx: %w", err)

Choose a reason for hiding this comment

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

medium

This string concatenation is unnecessary as the line is not exceeding the length limit. Combining it into a single string improves readability.1

return nil, fmt.Errorf("failed to serialize tx: %w", err)

Style Guide References

Footnotes

  1. The style guide recommends minimizing lines for log and error messages. While it allows splitting long strings, this string is short enough to be on a single line, which improves readability.

Comment on lines +1245 to +1249
/*
Optional. Whether to include the raw transaction hex in the response. This
is useful for cases where the transaction does not propagate and the caller
wants to manually broadcast it.
*/

Choose a reason for hiding this comment

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

medium

The comment for include_raw_tx should mention that setting this flag to true will cause the RPC call to block until the sweep transaction is created. This is a crucial detail for API users to understand the behavior of the call.

Suggested change
/*
Optional. Whether to include the raw transaction hex in the response. This
is useful for cases where the transaction does not propagate and the caller
wants to manually broadcast it.
*/
/*
Optional. Whether to include the raw transaction hex in the response. This
is useful for cases where the transaction does not propagate and the caller
wants to manually broadcast it. Note that setting this to true will cause
the RPC to block until the sweep transaction is created.
*/

@federicociro
Copy link
Author

Hi @yyforyongyu! I've added the timeout fix commit to address the flaky tests. Could you approve the workflow run when you have a chance? Thanks!

@lightninglabs-deploy
Copy link

@federicociro, remember to re-request review from reviewers when ready

@federicociro
Copy link
Author

Gentle ping @yyforyongyu when you have time 🙂

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.

[feature]: BumpFee: return raw tx hex on success

2 participants