mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-09 06:54:32 +02:00
sqldb+invoices: synchronize SQL invoice updater behavior with KV version
Previously SQL invoice updater ignored the set ID hint when updating an AMP invoice resulting in update subscriptions returning all of the AMP state as well as all AMP HTLCs. This commit synchornizes behavior with the KV implementation such that we now only return relevant AMP state and HTLCs when updating an AMP invoice.
This commit is contained in:
@ -26,7 +26,11 @@ WHERE invoice_id = $1;
|
||||
-- name: GetInvoice :many
|
||||
SELECT i.*
|
||||
FROM invoices i
|
||||
LEFT JOIN amp_sub_invoices a on i.id = a.invoice_id
|
||||
LEFT JOIN amp_sub_invoices a
|
||||
ON i.id = a.invoice_id
|
||||
AND (
|
||||
a.set_id = sqlc.narg('set_id') OR sqlc.narg('set_id') IS NULL
|
||||
)
|
||||
WHERE (
|
||||
i.id = sqlc.narg('add_index') OR
|
||||
sqlc.narg('add_index') IS NULL
|
||||
@ -39,13 +43,16 @@ WHERE (
|
||||
) AND (
|
||||
i.payment_addr = sqlc.narg('payment_addr') OR
|
||||
sqlc.narg('payment_addr') IS NULL
|
||||
) AND (
|
||||
a.set_id = sqlc.narg('set_id') OR
|
||||
sqlc.narg('set_id') IS NULL
|
||||
)
|
||||
GROUP BY i.id
|
||||
LIMIT 2;
|
||||
|
||||
-- name: GetInvoiceBySetID :many
|
||||
SELECT i.*
|
||||
FROM invoices i
|
||||
INNER JOIN amp_sub_invoices a
|
||||
ON i.id = a.invoice_id AND a.set_id = $1;
|
||||
|
||||
-- name: FilterInvoices :many
|
||||
SELECT
|
||||
invoices.*
|
||||
|
Reference in New Issue
Block a user