Skip to content

Custom channels itest: Use group keys on some payments & invoices #995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ require (
github.com/lightninglabs/pool v0.6.5-beta.0.20250305125211-4e860ec4e77f
github.com/lightninglabs/pool/auctioneerrpc v1.1.3-0.20250305125211-4e860ec4e77f
github.com/lightninglabs/pool/poolrpc v1.0.1-0.20250305125211-4e860ec4e77f
github.com/lightninglabs/taproot-assets v0.5.2-0.20250401150538-a9ea76a9ed3c
github.com/lightninglabs/taproot-assets v0.5.2-0.20250416114205-2da076df4b4e
github.com/lightningnetwork/lnd v0.19.0-beta.rc1.0.20250327183348-eb822a5e117f
github.com/lightningnetwork/lnd/cert v1.2.2
github.com/lightningnetwork/lnd/clock v1.1.1
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1181,8 +1181,8 @@ github.com/lightninglabs/pool/poolrpc v1.0.1-0.20250305125211-4e860ec4e77f h1:5p
github.com/lightninglabs/pool/poolrpc v1.0.1-0.20250305125211-4e860ec4e77f/go.mod h1:lGs2hSVZ+GFpdv3btaIl9icG5/gz7BBRfvmD2iqqNl0=
github.com/lightninglabs/protobuf-go-hex-display v1.34.2-hex-display h1:w7FM5LH9Z6CpKxl13mS48idsu6F+cEZf0lkyiV+Dq9g=
github.com/lightninglabs/protobuf-go-hex-display v1.34.2-hex-display/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
github.com/lightninglabs/taproot-assets v0.5.2-0.20250401150538-a9ea76a9ed3c h1:Rebx5DVZx3u327vKRrueFjZNlei1RzdGzFmOZmenkiQ=
github.com/lightninglabs/taproot-assets v0.5.2-0.20250401150538-a9ea76a9ed3c/go.mod h1:e3SjXbbi4xKhOzq54c672Z/j9UTRq5DLJGx/URgVTJo=
github.com/lightninglabs/taproot-assets v0.5.2-0.20250416114205-2da076df4b4e h1:37sk9Wmkh9QFjnqR8eHIhCi8x0uIQL0F2fpcQI25I9g=
github.com/lightninglabs/taproot-assets v0.5.2-0.20250416114205-2da076df4b4e/go.mod h1:e3SjXbbi4xKhOzq54c672Z/j9UTRq5DLJGx/URgVTJo=
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb h1:yfM05S8DXKhuCBp5qSMZdtSwvJ+GFzl94KbXMNB1JDY=
github.com/lightningnetwork/lightning-onion v1.2.1-0.20240712235311-98bd56499dfb/go.mod h1:c0kvRShutpj3l6B9WtTsNTBUtjSmjZXbJd9ZBRQOSKI=
github.com/lightningnetwork/lnd v0.19.0-beta.rc1.0.20250327183348-eb822a5e117f h1:+Bejv2Ij/ryUjLacBd5au0acMH0AYs0lhb7ki5rx9ms=
72 changes: 67 additions & 5 deletions itest/assets_test.go
Original file line number Diff line number Diff line change
@@ -741,6 +741,12 @@ func sendAssetKeySendPayment(t *testing.T, src, dst *HarnessNode, amt uint64,
opt(cfg)
}

// Nullify assetID if group key is set. RPC methods won't accept both so
// let's prioritize the group key if set.
if len(cfg.groupKey) > 0 {
assetID = nil
}

ctxb := context.Background()
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
defer cancel()
@@ -770,6 +776,7 @@ func sendAssetKeySendPayment(t *testing.T, src, dst *HarnessNode, amt uint64,
stream, err := srcTapd.SendPayment(ctxt, &tchrpc.SendPaymentRequest{
AssetId: assetID,
AssetAmount: amt,
GroupKey: cfg.groupKey,
PaymentRequest: sendReq,
})
require.NoError(t, err)
@@ -942,6 +949,7 @@ type payConfig struct {
payStatus lnrpc.Payment_PaymentStatus
failureReason lnrpc.PaymentFailureReason
rfq fn.Option[rfqmsg.ID]
groupKey []byte
}

func defaultPayConfig() *payConfig {
@@ -956,6 +964,12 @@ func defaultPayConfig() *payConfig {

type payOpt func(*payConfig)

func withGroupKey(groupKey []byte) payOpt {
return func(c *payConfig) {
c.groupKey = groupKey
}
}

func withSmallShards() payOpt {
return func(c *payConfig) {
c.smallShards = true
@@ -1010,6 +1024,12 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
opt(cfg)
}

// Nullify assetID if group key is set. RPC methods won't accept both so
// let's prioritize the group key if set.
if len(cfg.groupKey) > 0 {
assetID = []byte{}
}

ctxb := context.Background()
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
defer cancel()
@@ -1041,6 +1061,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
stream, err := payerTapd.SendPayment(ctxt, &tchrpc.SendPaymentRequest{
AssetId: assetID,
PeerPubkey: rfqPeer.PubKey[:],
GroupKey: cfg.groupKey,
PaymentRequest: sendReq,
RfqId: rfqBytes,
AllowOverpay: cfg.allowOverpay,
@@ -1102,6 +1123,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,

type invoiceConfig struct {
errSubStr string
groupKey []byte
}

func defaultInvoiceConfig() *invoiceConfig {
@@ -1118,6 +1140,12 @@ func withInvoiceErrSubStr(errSubStr string) invoiceOpt {
}
}

func withInvGroupKey(groupKey []byte) invoiceOpt {
return func(c *invoiceConfig) {
c.groupKey = groupKey
}
}

func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
assetAmount uint64, assetID []byte,
opts ...invoiceOpt) *lnrpc.AddInvoiceResponse {
@@ -1127,6 +1155,12 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
opt(cfg)
}

// Nullify assetID if group key is set. RPC methods won't accept both so
// let's prioritize the group key if set.
if len(cfg.groupKey) > 0 {
assetID = []byte{}
}

ctxb := context.Background()
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
defer cancel()
@@ -1141,6 +1175,7 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,

resp, err := dstTapd.AddInvoice(ctxt, &tchrpc.AddInvoiceRequest{
AssetId: assetID,
GroupKey: cfg.groupKey,
AssetAmount: assetAmount,
PeerPubkey: dstRfqPeer.PubKey[:],
InvoiceRequest: &lnrpc.Invoice{
@@ -1185,7 +1220,7 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
// individual HTLCs that arrived for it and that they show the correct asset
// amounts for the given ID when decoded.
func assertInvoiceHtlcAssets(t *testing.T, node *HarnessNode,
addedInvoice *lnrpc.AddInvoiceResponse, assetID []byte,
addedInvoice *lnrpc.AddInvoiceResponse, assetID []byte, groupID []byte,
assetAmount uint64) {

ctxb := context.Background()
@@ -1204,7 +1239,14 @@ func assertInvoiceHtlcAssets(t *testing.T, node *HarnessNode,

t.Logf("Asset invoice: %v", toProtoJSON(t, invoice))

targetID := hex.EncodeToString(assetID)
var targetID string
switch {
case len(groupID) > 0:
targetID = hex.EncodeToString(groupID)

case len(assetID) > 0:
targetID = hex.EncodeToString(assetID)
}

var totalAssetAmount uint64
for _, htlc := range invoice.Htlcs {
@@ -1231,7 +1273,7 @@ func assertInvoiceHtlcAssets(t *testing.T, node *HarnessNode,
// individual HTLCs that arrived for it and that they show the correct asset
// amounts for the given ID when decoded.
func assertPaymentHtlcAssets(t *testing.T, node *HarnessNode, payHash []byte,
assetID []byte, assetAmount uint64) {
assetID []byte, groupID []byte, assetAmount uint64) {

ctxb := context.Background()
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
@@ -1252,7 +1294,14 @@ func assertPaymentHtlcAssets(t *testing.T, node *HarnessNode, payHash []byte,

t.Logf("Asset payment: %v", toProtoJSON(t, payment))

targetID := hex.EncodeToString(assetID)
var targetID string
switch {
case len(groupID) > 0:
targetID = hex.EncodeToString(groupID)

case len(assetID) > 0:
targetID = hex.EncodeToString(assetID)
}

var totalAssetAmount uint64
for _, htlc := range payment.Htlcs {
@@ -1282,7 +1331,19 @@ type assetHodlInvoice struct {
}

func createAssetHodlInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
assetAmount uint64, assetID []byte) assetHodlInvoice {
assetAmount uint64, assetID []byte,
opts ...invoiceOpt) assetHodlInvoice {

cfg := defaultInvoiceConfig()
for _, opt := range opts {
opt(cfg)
}

// Nullify assetID if group key is set. RPC methods won't accept both so
// let's prioritize the group key if set.
if len(cfg.groupKey) > 0 {
assetID = []byte{}
}

ctxb := context.Background()
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
@@ -1306,6 +1367,7 @@ func createAssetHodlInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,

resp, err := dstTapd.AddInvoice(ctxt, &tchrpc.AddInvoiceRequest{
AssetId: assetID,
GroupKey: cfg.groupKey,
AssetAmount: assetAmount,
PeerPubkey: dstRfqPeer.PubKey[:],
InvoiceRequest: &lnrpc.Invoice{
Loading