Skip to content

Conversation

@MPins
Copy link
Contributor

@MPins MPins commented Jun 20, 2025

Change Description

Fixes #9591
Add Support for P2TR Fallback Addresses in BOLT-11 invoices

Steps to Test

lncli addinvoice --fallback_addr=bcrt1ps89hq0hxen5y6yxqqk88ssdyhe7hdr92fzudtcskk37p460ldazsl0sfsw

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 20, 2025

Important

Review skipped

Auto reviews are limited to specific labels.

🏷️ Labels to auto review (1)
  • llm-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@MPins MPins force-pushed the issue-9591 branch 5 times, most recently from 109c703 to 069f6d1 Compare June 22, 2025 00:51
@MPins
Copy link
Contributor Author

MPins commented Jul 7, 2025

/gemini review

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 adds support for Pay-to-Taproot (P2TR) fallback addresses in BOLT-11 invoices. The changes include updating the invoice decoding and encoding logic to handle P2TR addresses, along with corresponding unit tests. I recommend adding a full integration test case to TestDecodeEncode to ensure the end-to-end encoding and decoding of invoices with P2TR fallback addresses works as expected. This will improve test coverage and help prevent future regressions.

Copy link
Contributor

@GustavoStingelin GustavoStingelin left a comment

Choose a reason for hiding this comment

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

💯

@MPins
Copy link
Contributor Author

MPins commented Jul 31, 2025

@saubyk this PR could be included in the lnd v0.20.0 milestone.

@ziggie1984
Copy link
Collaborator

ziggie1984 commented Aug 1, 2025

#9591 also mentions a spec update for all implementation to behave the same is this also planed ? This should then include test vectors and those test vectors should be tested here.

@MPins
Copy link
Contributor Author

MPins commented Aug 1, 2025

#9591 also mentions a spec update for all implementation to behave the same is this also planed ? This should then include test vectors and those test vectors should be tested here.

Hello @ziggie1984, I just reached out to @erickcestari (who opened the issue). Our understanding is that the spec already states that a P2TR address must be accepted:

f (9): data_length variable, depending on version. Fallback on-chain address: for Bitcoin, this starts with a 5-bit version and contains a witness program or P2PKH or P2SH address.

Handling cases where more than one fallback address is provided may be left to each implementation. I’ll open a PR in BOLT to add the test vector I created for this PR.

@MPins
Copy link
Contributor Author

MPins commented Aug 7, 2025

Hello @ziggie1984 the PR#1276 adding the test vector for a p2tr fallback address in BOLT 11 has been submitted.

Just to clarify — the test vector in this PR doesn’t include the s (payment secret) and 9 (features) tagged fields, following the same pattern as the other test vectors already presented here.

@MPins
Copy link
Contributor Author

MPins commented Aug 14, 2025

Hello @ziggie1984 the PR#1276 adding the test vector for a p2tr fallback address in BOLT 11 has been submitted.

Just to clarify — the test vector in this PR doesn’t include the s (payment secret) and 9 (features) tagged fields, following the same pattern as the other test vectors already presented here.

Hello @ziggie1984, the BOLT PR just received its first approval.
As noted, the fallback address might be deprecated in the future, so I think we can move forward with this PR and have LND accept the P2TR fallback address in the same way it handles the other address types.

Copy link
Collaborator

@ziggie1984 ziggie1984 left a comment

Choose a reason for hiding this comment

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

Had some minor comments, other than that it is good to go

@lightninglabs-deploy
Copy link

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

@MPins MPins requested a review from ziggie1984 September 9, 2025 11:13
@MPins MPins force-pushed the issue-9591 branch 2 times, most recently from 4f34854 to 0f84100 Compare September 11, 2025 18:49
@MPins
Copy link
Contributor Author

MPins commented Sep 11, 2025

@ziggie1984 now it is using the P2TR test vector. Ready for your review.

Copy link
Collaborator

@ziggie1984 ziggie1984 left a comment

Choose a reason for hiding this comment

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

LGTM, I wonder how you created the invoice for the spec in the first place, was thinking you were using LND but doesn't look like it ?

@starius
Copy link
Collaborator

starius commented Sep 12, 2025

Manual testing of 0f84100 in signet:

$ lncli newaddress p2tr
{
    "address": "tb1prf2aym930gl4rx7tnvayexw3tcsg8n8nvy55a0rurqyqx6833a3q73rlx3"
}

$ lncli addinvoice --fallback_addr tb1prf2aym930gl4rx7tnvayexw3tcsg8n8nvy55a0rurqyqx6833a3q73rlx3
{
    "r_hash": "792e562ebe1fe61495d6852b5129338a04a3262069543f1fb01d6c531a9a5f4d",
    "payment_request": "lntbs1p5vgt47pp50yh9vt47rlnpf9wks544z2fn3gz2xf3qd92r78asr4k9xx56taxsdqqcqzzsxqyz5vqfp4prf2aym930gl4rx7tnvayexw3tcsg8n8nvy55a0rurqyqx6833a3qsp5dyg5ls0mxwq4hyw05q0qfydv8ccu6xfd7jvqu78d8nzrjktpw2uq9qxpqysgqn4ht9fxmt0srche7yv3zgseemapt85wjkej5ssskaqh6wc6clcx4n4rv624u4g8u4p57cupx3zdcjyw0057k78mjkunr62pwvswqe7cqqde48j",
    "add_index": "1",
    "payment_addr": "69114fc1fb33815b91cfa01e0491ac3e31cd192df4980e78ed3cc439596172b8"
}

$ lncli decodepayreq lntbs1p5vgt47pp50yh9vt47rlnpf9wks544z2fn3gz2xf3qd92r78asr4k9xx56taxsdqqcqzzsxqyz5vqfp4prf2aym930gl4rx7tnvayexw3tcsg8n8nvy55a0rurqyqx6833a3qsp5dyg5ls0mxwq4hyw05q0qfydv8ccu6xfd7jvqu78d8nzrjktpw2uq9qxpqysgqn4ht9fxmt0srche7yv3zgseemapt85wjkej5ssskaqh6wc6clcx4n4rv624u4g8u4p57cupx3zdcjyw0057k78mjkunr62pwvswqe7cqqde48j | jq .fallback_addr
"tb1prf2aym930gl4rx7tnvayexw3tcsg8n8nvy55a0rurqyqx6833a3q73rlx3"

Works as expected!

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! 🏆
The code looks great, pending comments.
I tested it manually in signet - works perfectly!

@MPins
Copy link
Contributor Author

MPins commented Sep 12, 2025

LGTM, I wonder how you created the invoice for the spec in the first place, was thinking you were using LND but doesn't look like it ?

Thanks!

Since I also needed to create an invalid invoice, I used lightning-payencode and modified it to fit my needs. I also submitted some PRs to make it compatible with the recent specs, but it seems Rusty is no longer maintaining the project.

@MPins
Copy link
Contributor Author

MPins commented Sep 12, 2025

LGTM! 🏆 The code looks great, pending comments. I tested it manually in signet - works perfectly!

Thanks! I’ve addressed all the comments, except for the one about encoding back the invoice — I left a reply on that thread with my thoughts. 😉

@ellemouton ellemouton merged commit 6b279fb into lightningnetwork:master Sep 15, 2025
37 of 39 checks passed
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]: Add Support for P2TR Fallback Addresses and Standardize Multiple Fallback Address Handling in BOLT-11

6 participants