Skip to content

Commit e152a52

Browse files
aakselrodRoasbeef
authored andcommitted
invoices/sqldb: query by ChanID when updating AMP invoice preimage
1 parent ce442a5 commit e152a52

File tree

6 files changed

+14
-6
lines changed

6 files changed

+14
-6
lines changed

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,13 @@ linters-settings:
104104
- 'errors.Wrap'
105105

106106
gomoddirectives:
107+
replace-local: true
107108
replace-allow-list:
108109
# See go.mod for the explanation why these are needed.
109110
- github.com/ulikunitz/xz
110111
- github.com/gogo/protobuf
111112
- google.golang.org/protobuf
113+
- github.com/lightningnetwork/lnd/sqldb
112114

113115

114116
linters:

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ replace github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2
204204
// allows us to specify that as an option.
205205
replace google.golang.org/protobuf => github.com/lightninglabs/protobuf-go-hex-display v1.30.0-hex-display
206206

207+
// Temporary replace until the next version of sqldb is taged.
208+
replace github.com/lightningnetwork/lnd/sqldb => ./sqldb
209+
207210
// If you change this please also update .github/pull_request_template.md,
208211
// docs/INSTALL.md and GO_IMAGE in lnrpc/gen_protos_docker.sh.
209212
go 1.21.4

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,6 @@ github.com/lightningnetwork/lnd/kvdb v1.4.10 h1:vK89IVv1oVH9ubQWU+EmoCQFeVRaC8kf
458458
github.com/lightningnetwork/lnd/kvdb v1.4.10/go.mod h1:J2diNABOoII9UrMnxXS5w7vZwP7CA1CStrl8MnIrb3A=
459459
github.com/lightningnetwork/lnd/queue v1.1.1 h1:99ovBlpM9B0FRCGYJo6RSFDlt8/vOkQQZznVb18iNMI=
460460
github.com/lightningnetwork/lnd/queue v1.1.1/go.mod h1:7A6nC1Qrm32FHuhx/mi1cieAiBZo5O6l8IBIoQxvkz4=
461-
github.com/lightningnetwork/lnd/sqldb v1.0.3 h1:zLfAwOvM+6+3+hahYO9Q3h8pVV0TghAR7iJ5YMLCd3I=
462-
github.com/lightningnetwork/lnd/sqldb v1.0.3/go.mod h1:4cQOkdymlZ1znnjuRNvMoatQGJkRneTj2CoPSPaQhWo=
463461
github.com/lightningnetwork/lnd/ticker v1.1.1 h1:J/b6N2hibFtC7JLV77ULQp++QLtCwT6ijJlbdiZFbSM=
464462
github.com/lightningnetwork/lnd/ticker v1.1.1/go.mod h1:waPTRAAcwtu7Ji3+3k+u/xH5GHovTsCoSVpho0KDvdA=
465463
github.com/lightningnetwork/lnd/tlv v1.2.3 h1:If5ibokA/UoCBGuCKaY6Vn2SJU0l9uAbehCnhTZjEP8=

invoices/sql_store.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,9 @@ func (s *sqlInvoiceUpdater) AddAmpHtlcPreimage(setID [32]byte,
11161116
SetID: setID[:],
11171117
HtlcID: int64(circuitKey.HtlcID),
11181118
Preimage: preimage[:],
1119+
ChanID: strconv.FormatUint(
1120+
circuitKey.ChanID.ToUint64(), 10,
1121+
),
11191122
},
11201123
)
11211124
if err != nil {

sqldb/sqlc/amp_invoices.sql.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sqldb/sqlc/queries/amp_invoices.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ WHERE (
6161

6262
-- name: UpdateAMPSubInvoiceHTLCPreimage :execresult
6363
UPDATE amp_sub_invoice_htlcs AS a
64-
SET preimage = $4
64+
SET preimage = $5
6565
WHERE a.invoice_id = $1 AND a.set_id = $2 AND a.htlc_id = (
66-
SELECT id FROM invoice_htlcs AS i WHERE i.htlc_id = $3
66+
SELECT id FROM invoice_htlcs AS i WHERE i.chan_id = $3 AND i.htlc_id = $4
6767
);

0 commit comments

Comments
 (0)