mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-28 13:57:01 +02:00
invoices/sqldb: query by ChanID when updating AMP invoice preimage
This commit is contained in:
committed by
Olaoluwa Osuntokun
parent
ce442a5083
commit
e152a52625
@@ -104,11 +104,13 @@ linters-settings:
|
|||||||
- 'errors.Wrap'
|
- 'errors.Wrap'
|
||||||
|
|
||||||
gomoddirectives:
|
gomoddirectives:
|
||||||
|
replace-local: true
|
||||||
replace-allow-list:
|
replace-allow-list:
|
||||||
# See go.mod for the explanation why these are needed.
|
# See go.mod for the explanation why these are needed.
|
||||||
- github.com/ulikunitz/xz
|
- github.com/ulikunitz/xz
|
||||||
- github.com/gogo/protobuf
|
- github.com/gogo/protobuf
|
||||||
- google.golang.org/protobuf
|
- google.golang.org/protobuf
|
||||||
|
- github.com/lightningnetwork/lnd/sqldb
|
||||||
|
|
||||||
|
|
||||||
linters:
|
linters:
|
||||||
|
3
go.mod
3
go.mod
@@ -204,6 +204,9 @@ replace github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2
|
|||||||
// allows us to specify that as an option.
|
// allows us to specify that as an option.
|
||||||
replace google.golang.org/protobuf => github.com/lightninglabs/protobuf-go-hex-display v1.30.0-hex-display
|
replace google.golang.org/protobuf => github.com/lightninglabs/protobuf-go-hex-display v1.30.0-hex-display
|
||||||
|
|
||||||
|
// Temporary replace until the next version of sqldb is taged.
|
||||||
|
replace github.com/lightningnetwork/lnd/sqldb => ./sqldb
|
||||||
|
|
||||||
// If you change this please also update .github/pull_request_template.md,
|
// If you change this please also update .github/pull_request_template.md,
|
||||||
// docs/INSTALL.md and GO_IMAGE in lnrpc/gen_protos_docker.sh.
|
// docs/INSTALL.md and GO_IMAGE in lnrpc/gen_protos_docker.sh.
|
||||||
go 1.21.4
|
go 1.21.4
|
||||||
|
2
go.sum
2
go.sum
@@ -458,8 +458,6 @@ github.com/lightningnetwork/lnd/kvdb v1.4.10 h1:vK89IVv1oVH9ubQWU+EmoCQFeVRaC8kf
|
|||||||
github.com/lightningnetwork/lnd/kvdb v1.4.10/go.mod h1:J2diNABOoII9UrMnxXS5w7vZwP7CA1CStrl8MnIrb3A=
|
github.com/lightningnetwork/lnd/kvdb v1.4.10/go.mod h1:J2diNABOoII9UrMnxXS5w7vZwP7CA1CStrl8MnIrb3A=
|
||||||
github.com/lightningnetwork/lnd/queue v1.1.1 h1:99ovBlpM9B0FRCGYJo6RSFDlt8/vOkQQZznVb18iNMI=
|
github.com/lightningnetwork/lnd/queue v1.1.1 h1:99ovBlpM9B0FRCGYJo6RSFDlt8/vOkQQZznVb18iNMI=
|
||||||
github.com/lightningnetwork/lnd/queue v1.1.1/go.mod h1:7A6nC1Qrm32FHuhx/mi1cieAiBZo5O6l8IBIoQxvkz4=
|
github.com/lightningnetwork/lnd/queue v1.1.1/go.mod h1:7A6nC1Qrm32FHuhx/mi1cieAiBZo5O6l8IBIoQxvkz4=
|
||||||
github.com/lightningnetwork/lnd/sqldb v1.0.3 h1:zLfAwOvM+6+3+hahYO9Q3h8pVV0TghAR7iJ5YMLCd3I=
|
|
||||||
github.com/lightningnetwork/lnd/sqldb v1.0.3/go.mod h1:4cQOkdymlZ1znnjuRNvMoatQGJkRneTj2CoPSPaQhWo=
|
|
||||||
github.com/lightningnetwork/lnd/ticker v1.1.1 h1:J/b6N2hibFtC7JLV77ULQp++QLtCwT6ijJlbdiZFbSM=
|
github.com/lightningnetwork/lnd/ticker v1.1.1 h1:J/b6N2hibFtC7JLV77ULQp++QLtCwT6ijJlbdiZFbSM=
|
||||||
github.com/lightningnetwork/lnd/ticker v1.1.1/go.mod h1:waPTRAAcwtu7Ji3+3k+u/xH5GHovTsCoSVpho0KDvdA=
|
github.com/lightningnetwork/lnd/ticker v1.1.1/go.mod h1:waPTRAAcwtu7Ji3+3k+u/xH5GHovTsCoSVpho0KDvdA=
|
||||||
github.com/lightningnetwork/lnd/tlv v1.2.3 h1:If5ibokA/UoCBGuCKaY6Vn2SJU0l9uAbehCnhTZjEP8=
|
github.com/lightningnetwork/lnd/tlv v1.2.3 h1:If5ibokA/UoCBGuCKaY6Vn2SJU0l9uAbehCnhTZjEP8=
|
||||||
|
@@ -1116,6 +1116,9 @@ func (s *sqlInvoiceUpdater) AddAmpHtlcPreimage(setID [32]byte,
|
|||||||
SetID: setID[:],
|
SetID: setID[:],
|
||||||
HtlcID: int64(circuitKey.HtlcID),
|
HtlcID: int64(circuitKey.HtlcID),
|
||||||
Preimage: preimage[:],
|
Preimage: preimage[:],
|
||||||
|
ChanID: strconv.FormatUint(
|
||||||
|
circuitKey.ChanID.ToUint64(), 10,
|
||||||
|
),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -268,15 +268,16 @@ func (q *Queries) InsertAMPSubInvoiceHTLC(ctx context.Context, arg InsertAMPSubI
|
|||||||
|
|
||||||
const updateAMPSubInvoiceHTLCPreimage = `-- name: UpdateAMPSubInvoiceHTLCPreimage :execresult
|
const updateAMPSubInvoiceHTLCPreimage = `-- name: UpdateAMPSubInvoiceHTLCPreimage :execresult
|
||||||
UPDATE amp_sub_invoice_htlcs AS a
|
UPDATE amp_sub_invoice_htlcs AS a
|
||||||
SET preimage = $4
|
SET preimage = $5
|
||||||
WHERE a.invoice_id = $1 AND a.set_id = $2 AND a.htlc_id = (
|
WHERE a.invoice_id = $1 AND a.set_id = $2 AND a.htlc_id = (
|
||||||
SELECT id FROM invoice_htlcs AS i WHERE i.htlc_id = $3
|
SELECT id FROM invoice_htlcs AS i WHERE i.chan_id = $3 AND i.htlc_id = $4
|
||||||
)
|
)
|
||||||
`
|
`
|
||||||
|
|
||||||
type UpdateAMPSubInvoiceHTLCPreimageParams struct {
|
type UpdateAMPSubInvoiceHTLCPreimageParams struct {
|
||||||
InvoiceID int64
|
InvoiceID int64
|
||||||
SetID []byte
|
SetID []byte
|
||||||
|
ChanID string
|
||||||
HtlcID int64
|
HtlcID int64
|
||||||
Preimage []byte
|
Preimage []byte
|
||||||
}
|
}
|
||||||
@@ -285,6 +286,7 @@ func (q *Queries) UpdateAMPSubInvoiceHTLCPreimage(ctx context.Context, arg Updat
|
|||||||
return q.db.ExecContext(ctx, updateAMPSubInvoiceHTLCPreimage,
|
return q.db.ExecContext(ctx, updateAMPSubInvoiceHTLCPreimage,
|
||||||
arg.InvoiceID,
|
arg.InvoiceID,
|
||||||
arg.SetID,
|
arg.SetID,
|
||||||
|
arg.ChanID,
|
||||||
arg.HtlcID,
|
arg.HtlcID,
|
||||||
arg.Preimage,
|
arg.Preimage,
|
||||||
)
|
)
|
||||||
|
@@ -61,7 +61,7 @@ WHERE (
|
|||||||
|
|
||||||
-- name: UpdateAMPSubInvoiceHTLCPreimage :execresult
|
-- name: UpdateAMPSubInvoiceHTLCPreimage :execresult
|
||||||
UPDATE amp_sub_invoice_htlcs AS a
|
UPDATE amp_sub_invoice_htlcs AS a
|
||||||
SET preimage = $4
|
SET preimage = $5
|
||||||
WHERE a.invoice_id = $1 AND a.set_id = $2 AND a.htlc_id = (
|
WHERE a.invoice_id = $1 AND a.set_id = $2 AND a.htlc_id = (
|
||||||
SELECT id FROM invoice_htlcs AS i WHERE i.htlc_id = $3
|
SELECT id FROM invoice_htlcs AS i WHERE i.chan_id = $3 AND i.htlc_id = $4
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user