12 Commits
Author SHA1 Message Date
ziggie 74f8f2d9e6 sqldb+payments: add payment_duplicates for legacy duplicate payments
Older LND versions could create multiple payments for the same hash.
We need to preserve those historical records during KV→SQL migration,
but they don’t fit the normal payment schema because we enforce a
unique payment hash constraint. Introduce a lean payment_duplicates
table to store only the essential fields (identifier, amount,
timestamps, settle/fail data).

This keeps the primary payment records stable and makes the migration
deterministic even when duplicate records lack attempt info. The table
is intentionally minimal and can be dropped after migration if no
duplicate payments exist.

For now there is no logic in place which allows the noderunner to
fetch duplicate payments after the migration.
2026-02-25 18:52:32 +01:00
ziggie 2596d34619 paymentsdb+sqldb: add migration related query
Add a migration specific query which allows to set the failure
reason when inserting a payment into the db.
2026-02-25 18:52:31 +01:00
ziggie 969b00e4a5 paymentsdb: implement FetchInFlightPayments for sql backend 2026-02-25 08:02:16 +01:00
ziggie ff12082452 paymentsdb: implement DeletePayments for sql backend 2026-02-25 08:02:16 +01:00
ziggie fd6796e561 multi: implement Fail method for sql backend 2026-02-25 08:02:15 +01:00
ziggie 510f6fb532 paymentsdb: implement InitPayment for sql backend 2026-02-25 08:02:09 +01:00
ziggie 0c96a2d722 sqldb+paymentsdb: add queries to insert all relavant data
In this commit we add all queries which we will need to insert
payment related data into the db.
2026-02-25 08:02:09 +01:00
ziggie 3012eb2ca0 paymentsdb: implement DeleteFailedAttempts for sql backend 2026-02-25 08:02:09 +01:00
ziggie 6faf68c5fa paymentsdb: add query to only fetch resolution type for HTLCs 2026-02-25 08:02:08 +01:00
ziggie bdea68bebf sqldb: add queries for deleting a payment and attempts 2026-02-25 08:02:08 +01:00
ziggie 27071acb6b sqldb: Change payment_intent relationship to payment table
Previously a one(intent)-to-many(payment) relationship it is now
changed to a one-to-one relationship because a payment request
only can have 1 payment related to it. Looking into the future
with BOLT12 offers, the fetched invoice from the offer could be
stored here as well and the relationship would still hold.
2026-02-25 08:02:08 +01:00
ziggie 18e7768837 multi: add relevant queries for QueryPayments implemenation 2026-02-25 08:02:04 +01:00