Skip to content

Conversation

ziggie1984
Copy link
Collaborator

@ziggie1984 ziggie1984 commented Oct 12, 2025

Depends on #9147

This PR implements the QueryPayments and FetchPayment SQL Payments DB backend functions.

It does not yet add testing for these functions which will be added in followup PRs once we have the ability to add payments and attempts to the database which we then can fetch.

@ziggie1984 ziggie1984 changed the base branch from master to elle-payment-sql-series-new October 12, 2025 17:19
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch 2 times, most recently from fe51267 to 63aa866 Compare October 12, 2025 17:33
@ziggie1984 ziggie1984 self-assigned this Oct 13, 2025
@ziggie1984 ziggie1984 added payments Related to invoices/payments sql labels Oct 13, 2025
@ziggie1984 ziggie1984 added this to v0.21 Oct 13, 2025
@ziggie1984 ziggie1984 added this to the v0.21.0 milestone Oct 13, 2025
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch from 938443e to b0361a2 Compare October 13, 2025 07:00
@ziggie1984 ziggie1984 added the database Related to the database/storage of LND label Oct 13, 2025
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch from b0361a2 to ed283fa Compare October 13, 2025 14:49
@saubyk saubyk moved this to In progress in v0.21 Oct 14, 2025
@ziggie1984 ziggie1984 changed the title [Part 2|*] Implement QueryPayments for SQL Backend [Part 2|*] Implement First Part for SQL Backend functions Oct 15, 2025
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch from ed283fa to aa560da Compare October 15, 2025 12:49
@ziggie1984 ziggie1984 marked this pull request as ready for review October 15, 2025 13:09
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch from aa560da to 08464ea Compare October 15, 2025 13:13
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch from 08464ea to da3603e Compare October 15, 2025 13:14
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch from da3603e to 069f7c6 Compare October 15, 2025 13:25
@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch 2 times, most recently from 1f7d395 to ef6ef5c Compare October 17, 2025 07:53
@ziggie1984
Copy link
Collaborator Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements the QueryPayments and FetchPayment functions for the new SQL backend of the payments database. The changes include new SQL queries, Go functions to execute them, and converters to transform database results into application-level types.

The implementation is well-structured, making good use of batching for efficient data fetching. I have a few suggestions to improve code clarity and adhere to best practices:

  • Simplify time value handling in sql_converters.go by using direct type assertions where the type is guaranteed.
  • Consider updating the DB interface to accept a context.Context in FetchPayment to avoid using context.TODO().
  • I also found a minor typo in a comment.

Overall, this is a solid contribution towards the SQL backend migration.

//
// This is part of the DB interface.
func (s *SQLStore) FetchPayment(paymentHash lntypes.Hash) (*MPPayment, error) {
ctx := context.TODO()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The use of context.TODO() is not ideal. The FetchPayment method in the DB interface should probably accept a context.Context to allow for cancellation and deadlines to be propagated. This would be a good improvement for a follow-up PR to align it with QueryPayments and other context-aware functions.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be done in a separate PR

@ziggie1984 ziggie1984 force-pushed the introduce-sql-schema-payments-part-2 branch from ef6ef5c to 0849296 Compare October 17, 2025 08:43
@ziggie1984 ziggie1984 moved this from In progress to In review in v0.21 Oct 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

database Related to the database/storage of LND payments Related to invoices/payments sql

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

1 participant