payments/db: fix silent error in duplicate payment lookup

When duplicatePaymentSequenceKey is missing from a duplicate payment
sub-bucket, the code returned the outer function's err variable which
is nil at that point. This caused corrupted duplicate entries to be
silently treated as "not found" instead of failing loudly.

Return a new dedicated ErrNoDuplicateSequenceNumber error so malformed
data is detected immediately.
This commit is contained in:
ziggie committed 2026-02-25 18:52:34 +01:00
1 parent c862e70148
commit 9def124380
2 files changed
+6 -1

No files matched your search

+5
View File
@@ -136,6 +136,11 @@ var (
ErrNoDuplicateNestedBucket = errors.New("nested duplicate bucket not " +
"found")
// ErrNoDuplicateSequenceNumber is returned when a duplicate payment
// sub-bucket does not contain the sequence number key.
ErrNoDuplicateSequenceNumber = errors.New("duplicate payment " +
"sequence number not found")
// ErrNoSequenceNrIndex is returned when an attempt to lookup a payment
// index is made for a sequence number that is not indexed.
//
+1 -1
View File
@@ -1236,7 +1236,7 @@ func fetchPaymentWithSequenceNumber(tx kvdb.RTx, paymentHash lntypes.Hash,
seqBytes := subBucket.Get(duplicatePaymentSequenceKey)
if seqBytes == nil {
return err
return ErrNoDuplicateSequenceNumber
}
// If this duplicate payment is not the sequence number we are