[v0.21.x-branch] Backport #10982: paymentsdb: normalize orphaned blinded total#10986
Merged
Merged
Conversation
SendToRouteV2 accepts caller-provided routes. It already required recipient-encrypted data when a blinding point was present. However, it copied a blinded total amount independently. This allowed a total-only hop to enter the payment database even though LND did not classify it as blinded. Require encrypted data when either blinded field is supplied. Cover the rejected combination, a valid blinded total and a regular hop. (cherry picked from commit ffc6250)
The KV route format stores blinded fields independently. Routes accepted through SendToRouteV2 could therefore contain a blinded total amount without encrypted recipient data. The SQL migration treated the total as proof of a blinded hop and bound nil to the required encrypted-data column, preventing LND from starting. Use encrypted recipient data as the blinded-hop discriminator and normalize only the known total-only case. Reject blinding-point-only records with payment, attempt and hop context instead of exposing an opaque SQL constraint error. Log normalized totals, account for them during migration validation, and cover both cases with regression tests. (cherry picked from commit 04da2fa)
Document the handling of historical total-only blinded route data and the new SendToRouteV2 validation that prevents creating such records. (cherry picked from commit 17ee638)
7 tasks
ziggie1984
approved these changes
Jul 22, 2026
ziggie1984
left a comment
Collaborator
There was a problem hiding this comment.
LGTM (no merge conflicts)
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.
Backport of #10982
Change Description
Fix a KV-to-SQL payment migration failure for historical routes containing a
non-zero blinded
total_amt_msatwithout encrypted recipient data.SendToRouteV2historically copied the blinded total amount independently ofthe encrypted data. LND did not classify such a hop as blinded at runtime, but
the migration treated the total amount as proof of a blinded hop and attempted
to insert a row with a NULL
encrypted_datavalue. This violated the existingSQL NOT NULL constraint and prevented LND from starting.
This PR:
SendToRouteV2supplies either ablinding point or blinded total amount;
representation;
attempt and hop context;
PYDBwarning identifying the affected payment, attempt, hop anddiscarded total amount;
Steps to Test
Pull Request Checklist
Testing
Code Style and Documentation
PYDBsubsystem at warning level.