Use backend invoice payment hash for settlement checks#2
Open
libertas-primordium wants to merge 1 commit into
Open
Use backend invoice payment hash for settlement checks#2libertas-primordium wants to merge 1 commit into
libertas-primordium wants to merge 1 commit into
Conversation
Store the payment hash returned by the Lightning backend when creating a pending LNURL purchase session instead of always storing the locally generated preimage hash. This fixes phoenixd-backed payment reconciliation because phoenixd creates invoices with its own payment hash while Europa previously stored the generated preimage hash and then polled phoenixd for a hash it did not recognize. Validated with pnpm install --frozen-lockfile, pnpm build, and pnpm test. Also validated on a live phoenixd-backed Europa node: after this change, a 100 sat Lightning purchase increased phoenixd balance, the session changed from pending to active automatically, and the WireGuard peer was added without manual database or wg intervention.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This fixes phoenixd-backed Lightning settlement reconciliation by storing the payment hash returned by the Lightning backend when creating a pending LNURL purchase session.
The existing code generated a local preimage/payment hash and stored that generated hash in the session row. With phoenixd, however, the invoice returned by
createinvoicehas its own backend-createdpaymentHash. Settlement polling later checks the stored session hash, so phoenixd-backed sessions can remain pending even after the invoice is paid because Europa is polling phoenixd for a hash phoenixd does not recognize.This change stores
invoice.paymentHash || paymentHash, preserving the existing fallback behavior while using the actual backend-created invoice hash when available.Validation
pnpm install --frozen-lockfilepnpm buildpnpm testpendingtoactiveautomaticallywginterventionNotes
This patch only fixes phoenixd-backed payment reconciliation by storing the payment hash returned by the backend-created invoice.
There is a separate phoenixd-related issue with the LNURL
successActionresponse. Europa currently encrypts the AESsuccessActionusing its locally generated preimage, but phoenixd creates the actual payable invoice with its own preimage/payment hash. As a result, the wallet that sends the payment receives a different payment preimage and cannot decrypt the returnedsuccessActionpayload. In live testing, the session activated correctly after this patch, but Phoenix Wallet Android still crashed when trying to view the payment receipt/config.That appears to require a separate design fix: either phoenixd would need to support caller-supplied invoice preimages/payment hashes, or Europa’s phoenixd backend should use a different authenticated config-delivery flow instead of AES
successAction.