Commit Graph
20282 Commits
Author SHA1 Message Date
ziggie 080fd78fb4 paymentsdb: introduce a harness interface
The design of the sql and kv db are a bit different. A harness
interface is introduced which allows us to unit most of the test
and keep the backend specific tests at a minimum.
2026-02-25 08:02:17 +01:00
ziggie 570863ca26 paymentsdb: add harness to run payment db agnostic tests
In commit adds the harness which will be used to run db agnostic
tests against the kv and sql backend. We have adopted all the
unit tests so far so that with this commit all the payment tests
not specifically put into the kv_store_test.go should all pass
for all backends.
2026-02-25 08:02:17 +01:00
ziggie 2eadbfb54d paymentsdb: fix test case before testing sql backend
We are now not supporting the LegacyPayload for the onion packet
anymore. All payments and their onion payload need to be tlv
encoded. The sql backend assumes tlv so we have to always set the
in memory presentation of a hop where the legacy parameter is still
available but deprecated to false, otherwise the hops will not be
equal and unit tests for the sql backend will fail when switched
on in the next commits.
2026-02-25 08:02:17 +01:00
ziggie de50f471e8 paymentsdb: make QueryPayments test db agnostic
We make the QueryPayments test db agnostic and also keep a small
test for querying the duplicate payments case in the kv world.
2026-02-25 08:02:17 +01:00
ziggie fdfa1430f8 paymentsdb: refactor test helpers
Since now the sql backend is more strict in using the same
session key we refactor the helper so that we can easily change
the session key for every new attempt.
2026-02-25 08:02:17 +01:00
ziggie 9ad3f2195b paymentsdb: remove kvstore from sql db implementation
Now that every method of the interface was implemented we can
remove the embedded reference we put into place for the sql store
implementation so that the interface would succeed. This is now
removed.
2026-02-25 08:02:17 +01:00
ziggie c919d25619 docs: add release-notes 2026-02-25 08:02:16 +01:00
ziggie 4e52896cc1 paymentsdb: added unit test for computePaymentStatusFromResolutions 2026-02-25 08:02:16 +01:00
ziggie 969b00e4a5 paymentsdb: implement FetchInFlightPayments for sql backend 2026-02-25 08:02:16 +01:00
ziggie 82ee78c5ef paymentsdb: use batch function when querying for resolutions 2026-02-25 08:02:16 +01:00
ziggie b02531cc85 paymentsdb: rename functions and variables
We take inspiration from the graph sql implementation and name
the variables accordingly.
2026-02-25 08:02:16 +01:00
ziggie 218a30d16e paymentsdb: add a wrapper to the fetchpayment method
We wrap the fetchPayment db call and catch the case where no errors
are found in the db, where we now return the ErrPaymentNotInitiated
error.
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 53a7877af0 paymentsdb: implement FailAttempt for sql backend 2026-02-25 08:02:15 +01:00
ziggie fd6796e561 multi: implement Fail method for sql backend 2026-02-25 08:02:15 +01:00
ziggie caf73c59da paymentsdb: rename paymentsBatchData
We rename this variable to paymentsDetailsData because we will
also need to batch load the core payment and intent data in
future commits and this renaming should make it clear that this
does match payment related data but not the core data which is
in the payment and in the intent table.
2026-02-25 08:02:15 +01:00
ziggie 5d328c976e paymentsdb: remove pointer receiver dependecy to make it more robust
We remove the SQLStore from most of the helper functions. This
also makes sure we do not accidentally create a new db tx but use
the provided db SQLQueries parameter.
2026-02-25 08:02:15 +01:00
ziggie 7d87c0ce2f paymentsdb: fix formatting for sql QueryPayments 2026-02-25 08:02:15 +01:00
ziggie 4c867c1b88 docs: add release-notes 2026-02-25 08:02:15 +01:00
ziggie 620dacc432 paymentsdb: implement SettleAttempt for sql backend 2026-02-25 08:02:14 +01:00
ziggie c0e55b5855 paymentsdb: verify total amount for last hop in the blinded path 2026-02-25 08:02:14 +01:00
ziggie 40c8502fd3 paymentsdb: implement RegisterAttempt for sql backend 2026-02-25 08:02:14 +01:00
ziggie d2cdd9d86f paymentsdb: add note to RegisterAttempt 2026-02-25 08:02:14 +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 c3e25ff8ef paymentsdb: implement DeletePayment for sql backend 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 f8241748a1 paymentsdb: enhance some godoc function descriptions 2026-02-25 08:02:08 +01:00
ziggie 4c5eaad606 docs: add release-notes 2026-02-25 08:02:08 +01:00
ziggie 8aae9ffc2c paymentsdb: implement FetchPayment for sql backend 2026-02-25 08:02:08 +01:00
ziggie e8fe45fe65 paymentsdb: implement QueryPayments for sql backend 2026-02-25 08:02:08 +01:00
ziggie eeca189b87 paymentsdb: add new internal error 2026-02-25 08:02:07 +01:00
ziggie 18e7768837 multi: add relevant queries for QueryPayments implemenation 2026-02-25 08:02:04 +01:00
ziggie e7a3096621 sqldb: add index and comment to payment tables 2026-02-25 08:01:16 +01:00
ziggie b6a05f7951 docs: add release-notes 2026-02-25 08:01:15 +01:00
ziggie 8c7b2367e5 lnd: make the payment schema migration available for testing
We allow the migration of the payment schema to be applied when
the test_native_sql is active to make sure the tables are properly
contructed.
2026-02-25 08:01:15 +01:00
ziggie dd585a821b sqldb: add payment sql tables
This does not include duplicate payments yet. They will be added
when the migration code is introduced for payments.
2026-02-25 08:01:15 +01:00
ziggie 93626822f7 lnd+paymentsdb: introduce harness for the payment sql backend
We prepare the code for the sql payment backend. However no
payment db interface method for the sql backend is implemented
yet. This will be done in the following commits. They currently
use the embedded KVStore to satify the build environment.
2026-02-25 08:01:14 +01:00
Olaoluwa Osuntokun 0b00c66231 Merge pull request #10601 from ziggie1984/invoice-filter-index-optimization
invoices/sql_store: replace catch-all FilterInvoices with targeted index-friendly queries
2026-02-24 16:34:27 -08:00
Yong 344af33ac7 Merge pull request #10557 from Liongrass/master
Remove redundant documentation from /docs
2026-02-24 21:17:22 +08:00
ziggieXXX c81d69e56a Merge pull request #10586 from GeorgeTsagk/add-george-key
scripts: add gpg key for georgetsagk
2026-02-23 16:01:52 +01:00
George Tsagkarelis 05d1df6de1 scripts: add gpg key for georgetsagk 2026-02-23 14:40:07 +01:00
Elle dd65ba2b01 Merge pull request #10543 from bitromortac/2602-channel-update-events
rpc: add channel updates to SubscribeChannelEvents
2026-02-23 13:09:36 +02:00
ziggie 1e5e6f27ef docs: add release notes for invoice SQL query performance improvements 2026-02-21 17:05:44 +01:00
ziggie d26bf84843 invoices/sql_store: add tests for targeted invoice query variants
Add testFetchPendingInvoicesAccepted to explicitly verify the state
filtering behaviour of FetchPendingInvoices across all four contract
states:

  ContractOpen     (state 0) – must be returned
  ContractAccepted (state 3) – must be returned
  ContractSettled  (state 1) – must be excluded
  ContractCanceled (state 2) – must be excluded

This directly exercises the `state IN (0, 3)` predicate introduced in
the FetchPendingInvoices SQL query and addresses the review request for
explicit test coverage of the new targeted query variants. The test
runs against the KV, SQLite, and Postgres backends.
2026-02-21 17:05:44 +01:00
ziggie 9becdfa8a3 sqldb/sqlc: remove deprecated FilterInvoices query
All call sites have been migrated to the targeted replacement queries
in the previous commit. Remove FilterInvoices and its associated
params struct from the SQL source and regenerate.
2026-02-21 16:58:31 +01:00
ziggie 774ebaf126 invoices/sql_store: switch to targeted queries, default timestamp bounds
Replace all four FilterInvoices call sites with the focused queries
introduced in the previous commit:

  FetchPendingInvoices   → FetchPendingInvoices
  InvoicesSettledSince   → FilterInvoicesBySettleIndex
  InvoicesAddedSince     → FilterInvoicesByAddIndex
  QueryInvoices          → FilterInvoicesForward / FilterInvoicesReverse

The first three are straight 1:1 swaps — the new params structs carry
only the fields that are actually used, and the removed fields (Reverse,
PendingOnly, unused index bounds) were always left at their zero values.

QueryInvoices is restructured more substantially. The forward/reverse
branch now selects between FilterInvoicesForward and
FilterInvoicesReverse, each of which takes a concrete id bound that is
always set:

  forward: AddIndexGet = IndexOffset + 1   (≥ 1 when IndexOffset = 0)
  reverse: AddIndexLet = IndexOffset - 1   (or MaxInt64 when offset = 0)

Timestamp parameters are changed from nullable (sql.NullTime with
OR-based SQL fallbacks) to always-on Go-side defaults, consistent with
the approach used by the payments query:

  createdAfter  → time.Unix(0, 0).UTC()          (epoch, before any invoice)
  createdBefore → time.Date(9999, 12, 31, …)     (far future, no upper cap)

This ensures the planner always sees plain range predicates on
created_at and can use the invoices_created_at_idx index.

The SQLInvoiceQueries interface is updated to expose the five new
methods and drop FilterInvoices.
2026-02-21 16:57:08 +01:00