Update AddHoldInvoice to add support for optional preimage/hash generation#10685
Update AddHoldInvoice to add support for optional preimage/hash generation#10685saubyk wants to merge 3 commits intolightningnetwork:masterfrom
Conversation
Make the hash field optional in AddHoldInvoiceRequest and add a new preimage field. When neither hash nor preimage is provided, the server auto-generates a random preimage and derives the hash. When a preimage is provided, the server validates it and derives the hash from it. The response now includes payment_preimage (populated when the server knows the preimage) and payment_hash (always populated), giving callers everything needed for the full hold invoice lifecycle. This leverages the existing mppPaymentHashAndPreimage logic in AddInvoiceData which already handles all four input combinations.
Add --hash and --preimage flags to the lncli addholdinvoice command. The old positional hash argument still works for backward compatibility (detected by 64 hex char length). The --preimage flag is validated client-side to be exactly 64 hex characters. When neither flag is provided, the server auto-generates both values.
Add integration test covering all four AddHoldInvoice input modes: auto-generate (neither hash nor preimage), user-supplied preimage, hash-only (backward compat), and the error case when both are set. Each subtest verifies the full payment lifecycle including settle.
Summary of ChangesHello, 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 AddHoldInvoice functionality by introducing more flexible preimage and hash management. It allows users to either provide a preimage for the server to derive a hash from, or opt for the server to auto-generate both a preimage and hash. The changes include updates to the RPC interface, command-line tool, and server-side logic, ensuring backward compatibility while providing robust error handling for invalid configurations. Highlights
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request enhances the AddHoldInvoice RPC and CLI command to support optional hash and preimage parameters. Users can now provide a preimage directly (from which the server derives the hash), provide a hash as before, or provide neither to have the server auto-generate both. The changes include updates to the protobuf definitions, CLI flag handling, server-side logic, and a comprehensive integration test suite. I have no feedback to provide.
Fixes #7220
Change Description
Update AddHoldInvoice to add support for optional preimage/hash generation. Following scenarios are handled:
Steps to Test
Pull Request Checklist
Testing
Code Style and Documentation
[skip ci]in the commit message for small changes.📝 Please see our Contribution Guidelines for further guidance.