sqldb: add index and comment to payment tables
What changed, and why it matters
This commit is a routine database schema update for LND. It adds a unique index to prevent duplicate payment intents and improves a code comment explaining how failure messages are stored. There is no security-relevant change visible in the diff.
No security action required. Treat as normal schema maintenance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The migration file 000009_payments.up.sql is modified to add a UNIQUE INDEX on (intent_type, intent_payload) in the payment_intents table and to expand an inline comment for the failure_msg BLOB column in payment_htlc_attempt_resolutions, noting it is binary-encoded lightning wire protocol data. No constraints are relaxed, no permissions change, no cryptographic handling is altered, and no input validation is modified.
Changed components
sqldb/sqlc/migrations/000009_payments.up.sqlInspect captured patch +7 / −2
diff --git a/sqldb/sqlc/migrations/000009_payments.up.sql b/sqldb/sqlc/migrations/000009_payments.up.sql
index c856db8..0d85b49 100644
--- a/sqldb/sqlc/migrations/000009_payments.up.sql
+++ b/sqldb/sqlc/migrations/000009_payments.up.sql
@@ -32,9 +32,13 @@ CREATE TABLE IF NOT EXISTS payment_intents (
);
-- Index for efficient querying by intent type
-CREATE INDEX IF NOT EXISTS idx_payment_intents_type
+CREATE INDEX IF NOT EXISTS idx_payment_intents_type
ON payment_intents(intent_type);
+-- Unique constraint for deduplication of payment intents
+CREATE UNIQUE INDEX IF NOT EXISTS idx_payment_intents_unique
+ON payment_intents(intent_type, intent_payload);
+
-- ─────────────────────────────────────────────
-- Payments Table
-- ─────────────────────────────────────────────
@@ -187,7 +191,8 @@ CREATE TABLE IF NOT EXISTS payment_htlc_attempt_resolutions (
-- HTLC failure reason code
htlc_fail_reason INTEGER,
- -- Failure message from the failing node
+ -- Failure message from the failing node, this message is binary encoded
+ -- using the lightning wire protocol, see also lnwire/onion_error.go
failure_msg BLOB,
-- Ensure data integrity: settled attempts must have preimage,
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.