What changed, and why it matters
This commit simply removes an unused database query and its generated code. It is a cleanup change with no security relevance.
No action needed. This is a routine code-cleanup commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit deletes the FetchAllInflightAttempts SQL query, its sqlc-generated Go bindings, and its interface declarations. The commit message states this old query surface is no longer used because FetchInFlightPayments now relies on a newer FetchNonTerminalPayments query. There is no functional behavior change, no bug fix, and no security-sensitive modification.
Changed components
payments/db/sql_store.gosqldb/sqlc/payments.sql.gosqldb/sqlc/querier.gosqldb/sqlc/queries/payments.sqlInspect captured patch +0 / −90
diff --git a/payments/db/sql_store.go b/payments/db/sql_store.go
index 960ad41..ed12a57 100644
--- a/payments/db/sql_store.go
+++ b/payments/db/sql_store.go
@@ -55,7 +55,6 @@ type SQLQueries interface {
FetchHtlcAttemptsForPayments(ctx context.Context, paymentIDs []int64) ([]sqlc.FetchHtlcAttemptsForPaymentsRow, error)
FetchHtlcAttemptResolutionsForPayments(ctx context.Context, paymentIDs []int64) ([]sqlc.FetchHtlcAttemptResolutionsForPaymentsRow, error)
- FetchAllInflightAttempts(ctx context.Context, arg sqlc.FetchAllInflightAttemptsParams) ([]sqlc.PaymentHtlcAttempt, error)
FetchHopsForAttempts(ctx context.Context, htlcAttemptIndices []int64) ([]sqlc.FetchHopsForAttemptsRow, error)
FetchPaymentDuplicates(ctx context.Context, paymentID int64) ([]sqlc.PaymentDuplicate, error)
diff --git a/sqldb/sqlc/payments.sql.go b/sqldb/sqlc/payments.sql.go
index 5afc7a1..aa52129 100644
--- a/sqldb/sqlc/payments.sql.go
+++ b/sqldb/sqlc/payments.sql.go
@@ -104,69 +104,6 @@ func (q *Queries) FailPayment(ctx context.Context, arg FailPaymentParams) (sql.R
return q.db.ExecContext(ctx, failPayment, arg.FailReason, arg.PaymentIdentifier)
}
-const fetchAllInflightAttempts = `-- name: FetchAllInflightAttempts :many
-SELECT
- ha.id,
- ha.attempt_index,
- ha.payment_id,
- ha.session_key,
- ha.attempt_time,
- ha.payment_hash,
- ha.first_hop_amount_msat,
- ha.route_total_time_lock,
- ha.route_total_amount,
- ha.route_source_key
-FROM payment_htlc_attempts ha
-WHERE NOT EXISTS (
- SELECT 1 FROM payment_htlc_attempt_resolutions hr
- WHERE hr.attempt_index = ha.attempt_index
-)
-AND ha.attempt_index > $1
-ORDER BY ha.attempt_index ASC
-LIMIT $2
-`
-
-type FetchAllInflightAttemptsParams struct {
- AttemptIndex int64
- Limit int32
-}
-
-// Fetch all inflight attempts with their payment data using pagination.
-// Returns attempt data joined with payment and intent data to avoid separate queries.
-func (q *Queries) FetchAllInflightAttempts(ctx context.Context, arg FetchAllInflightAttemptsParams) ([]PaymentHtlcAttempt, error) {
- rows, err := q.db.QueryContext(ctx, fetchAllInflightAttempts, arg.AttemptIndex, arg.Limit)
- if err != nil {
- return nil, err
- }
- defer rows.Close()
- var items []PaymentHtlcAttempt
- for rows.Next() {
- var i PaymentHtlcAttempt
- if err := rows.Scan(
- &i.ID,
- &i.AttemptIndex,
- &i.PaymentID,
- &i.SessionKey,
- &i.AttemptTime,
- &i.PaymentHash,
- &i.FirstHopAmountMsat,
- &i.RouteTotalTimeLock,
- &i.RouteTotalAmount,
- &i.RouteSourceKey,
- ); err != nil {
- return nil, err
- }
- items = append(items, i)
- }
- if err := rows.Close(); err != nil {
- return nil, err
- }
- if err := rows.Err(); err != nil {
- return nil, err
- }
- return items, nil
-}
-
const fetchHopLevelCustomRecords = `-- name: FetchHopLevelCustomRecords :many
SELECT
l.id,
diff --git a/sqldb/sqlc/querier.go b/sqldb/sqlc/querier.go
index b2f4633..3c16292 100644
--- a/sqldb/sqlc/querier.go
+++ b/sqldb/sqlc/querier.go
@@ -40,9 +40,6 @@ type Querier interface {
FailPayment(ctx context.Context, arg FailPaymentParams) (sql.Result, error)
FetchAMPSubInvoiceHTLCs(ctx context.Context, arg FetchAMPSubInvoiceHTLCsParams) ([]FetchAMPSubInvoiceHTLCsRow, error)
FetchAMPSubInvoices(ctx context.Context, arg FetchAMPSubInvoicesParams) ([]AmpSubInvoice, error)
- // Fetch all inflight attempts with their payment data using pagination.
- // Returns attempt data joined with payment and intent data to avoid separate queries.
- FetchAllInflightAttempts(ctx context.Context, arg FetchAllInflightAttemptsParams) ([]PaymentHtlcAttempt, error)
FetchHopLevelCustomRecords(ctx context.Context, hopIds []int64) ([]PaymentHopCustomRecord, error)
FetchHopsForAttempts(ctx context.Context, htlcAttemptIndices []int64) ([]FetchHopsForAttemptsRow, error)
// Batch query to fetch only HTLC resolution status for multiple payments.
diff --git a/sqldb/sqlc/queries/payments.sql b/sqldb/sqlc/queries/payments.sql
index 6473ef6..6910d1b 100644
--- a/sqldb/sqlc/queries/payments.sql
+++ b/sqldb/sqlc/queries/payments.sql
@@ -125,29 +125,6 @@ LEFT JOIN payment_intents pi ON pi.payment_id = p.id
WHERE p.id IN (sqlc.slice('payment_ids')/*SLICE:payment_ids*/)
ORDER BY p.id ASC;
--- name: FetchAllInflightAttempts :many
--- Fetch all inflight attempts with their payment data using pagination.
--- Returns attempt data joined with payment and intent data to avoid separate queries.
-SELECT
- ha.id,
- ha.attempt_index,
- ha.payment_id,
- ha.session_key,
- ha.attempt_time,
- ha.payment_hash,
- ha.first_hop_amount_msat,
- ha.route_total_time_lock,
- ha.route_total_amount,
- ha.route_source_key
-FROM payment_htlc_attempts ha
-WHERE NOT EXISTS (
- SELECT 1 FROM payment_htlc_attempt_resolutions hr
- WHERE hr.attempt_index = ha.attempt_index
-)
-AND ha.attempt_index > $1
-ORDER BY ha.attempt_index ASC
-LIMIT $2;
-
-- name: FetchNonTerminalPayments :many
-- Fetch all non-terminal payments using pagination. A payment is
-- non-terminal if it has an unresolved attempt, or if it has not been
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.