Skip to content

cmd: addinvoice --qr to print invoice QR#10638

Open
hieblmi wants to merge 2 commits intolightningnetwork:masterfrom
hieblmi:invoice-qr
Open

cmd: addinvoice --qr to print invoice QR#10638
hieblmi wants to merge 2 commits intolightningnetwork:masterfrom
hieblmi:invoice-qr

Conversation

@hieblmi
Copy link
Collaborator

@hieblmi hieblmi commented Mar 9, 2026

Optionally print the QR code of an invoice, added with lncli addinvoice --amt 1010 --qr

image

@gemini-code-assist
Copy link

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 enhances the lncli command-line tool by integrating a QR code generation feature for invoices. Users can now opt to display a scannable QR code for their payment requests directly in the terminal, significantly improving the ease of use for mobile wallet integration and streamlining the payment process.

Highlights

  • New Feature: QR Code Display: Introduced a new --qr flag to the addinvoice command, allowing users to display a QR code of the generated payment request directly in the terminal.
  • Dependency Update: Added a new Go module dependency, github.com/mdp/qrterminal/v3, to facilitate QR code generation and display.
  • Documentation: Updated the release notes for version 0.21.0 to reflect the addition of the --qr flag.

🧠 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
  • cmd/commands/cmd_invoice.go
    • Added os and qrterminal imports.
    • Introduced a new cli.BoolFlag named qr to the AddInvoiceCommand.
    • Implemented logic to generate and print a half-block QR code of the PaymentRequest to os.Stdout if the qr flag is set.
  • docs/release-notes/release-notes-0.21.0.md
    • Added a new entry documenting the --qr flag for the addinvoice command under the 'New Features' section.
  • go.mod
    • Added github.com/mdp/qrterminal/v3 and rsc.io/qr as indirect dependencies.
  • go.sum
    • Updated checksums for the newly added github.com/mdp/qrterminal/v3 and rsc.io/qr dependencies.
Activity
  • No human activity has been recorded for this pull request yet.
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 useful feature to display a QR code for an invoice via the --qr flag in the addinvoice command. The implementation is straightforward and correct. I have one suggestion to add a comment to the new code block to align with the repository's style guide regarding code documentation.

@hieblmi hieblmi marked this pull request as draft March 9, 2026 13:07
@hieblmi hieblmi changed the title Invoice qr cmd: addinvoice --qr to print invoice QR Mar 9, 2026
@hieblmi hieblmi self-assigned this Mar 9, 2026
@hieblmi hieblmi added the lncli label Mar 9, 2026
@hieblmi hieblmi requested a review from ziggie1984 March 9, 2026 13:51
@hieblmi hieblmi marked this pull request as ready for review March 9, 2026 14:21
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.

Have you tested this with a bigger invoice including blinded paths ? I wonder what is the information limit for this QR code representation ?

go.mod Outdated
)

require (
github.com/mdp/qrterminal/v3 v3.2.1 // indirect
Copy link
Collaborator

Choose a reason for hiding this comment

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

why are these in a separarte required block ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved them, fixed.

@hieblmi
Copy link
Collaborator Author

hieblmi commented Mar 10, 2026

Have you tested this with a bigger invoice including blinded paths ? I wonder what is the information limit for this QR code representation ?

You really have to dial down the font size of your terminal to make the QR code fit onto the screen, but it works.

On the limits:

QR code max: 4,296 alphanumeric characters (version 40, error correction L). Since bech32 invoices are alphanumeric, this is the effective limit.                                                                      
                                                                                                                                                                                                                       
  Blinded route size: There's no hard protocol max, but practically:                                                                                                                                                     
  - A standard invoice: ~300-400 chars                                                                                                                                                                                   
  - With 1 blinded path (2-3 hops): ~600-800 chars                                                                                                                                                                       
  - With 3 blinded paths (3-5 hops each): ~1,200-2,000 chars                                                                                                                                                           
  - Extreme cases: could exceed 3,000+ chars         

  So even large blinded invoices should fit within the QR limit. No need to disable --qr for blinded paths.
image

hieblmi added 2 commits March 10, 2026 09:54
Add a `--qr` flag to the `addinvoice` CLI command that renders the
payment request as a QR code directly in the terminal using the
qrterminal library. This makes it convenient to scan invoices from
a mobile wallet without needing to copy-paste the payment request
string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants