@@ -726,6 +726,12 @@ func sendAssetKeySendPayment(t *testing.T, src, dst *HarnessNode, amt uint64,
726726		opt (cfg )
727727	}
728728
729+ 	// Nullify assetID if group key is set. RPC methods won't accept both so 
730+ 	// let's prioritize the group key if set. 
731+ 	if  len (cfg .groupKey ) >  0  {
732+ 		assetID  =  nil 
733+ 	}
734+ 
729735	ctxb  :=  context .Background ()
730736	ctxt , cancel  :=  context .WithTimeout (ctxb , defaultTimeout )
731737	defer  cancel ()
@@ -755,6 +761,7 @@ func sendAssetKeySendPayment(t *testing.T, src, dst *HarnessNode, amt uint64,
755761	stream , err  :=  srcTapd .SendPayment (ctxt , & tchrpc.SendPaymentRequest {
756762		AssetId :        assetID ,
757763		AssetAmount :    amt ,
764+ 		GroupKey :       cfg .groupKey ,
758765		PaymentRequest : sendReq ,
759766	})
760767	require .NoError (t , err )
@@ -927,6 +934,7 @@ type payConfig struct {
927934	payStatus          lnrpc.Payment_PaymentStatus 
928935	failureReason      lnrpc.PaymentFailureReason 
929936	rfq                fn.Option [rfqmsg.ID ]
937+ 	groupKey           []byte 
930938}
931939
932940func  defaultPayConfig () * payConfig  {
@@ -941,6 +949,16 @@ func defaultPayConfig() *payConfig {
941949
942950type  payOpt  func (* payConfig )
943951
952+ func  withMaybeGroupKey (groupMode  bool , groupKey  []byte ) payOpt  {
953+ 	return  func (c  * payConfig ) {
954+ 		if  ! groupMode  {
955+ 			return 
956+ 		}
957+ 
958+ 		c .groupKey  =  groupKey 
959+ 	}
960+ }
961+ 
944962func  withSmallShards () payOpt  {
945963	return  func (c  * payConfig ) {
946964		c .smallShards  =  true 
@@ -995,6 +1013,12 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
9951013		opt (cfg )
9961014	}
9971015
1016+ 	// Nullify assetID if group key is set. RPC methods won't accept both so 
1017+ 	// let's prioritize the group key if set. 
1018+ 	if  len (cfg .groupKey ) >  0  {
1019+ 		assetID  =  []byte {}
1020+ 	}
1021+ 
9981022	ctxb  :=  context .Background ()
9991023	ctxt , cancel  :=  context .WithTimeout (ctxb , defaultTimeout )
10001024	defer  cancel ()
@@ -1026,6 +1050,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
10261050	stream , err  :=  payerTapd .SendPayment (ctxt , & tchrpc.SendPaymentRequest {
10271051		AssetId :        assetID ,
10281052		PeerPubkey :     rfqPeer .PubKey [:],
1053+ 		GroupKey :       cfg .groupKey ,
10291054		PaymentRequest : sendReq ,
10301055		RfqId :          rfqBytes ,
10311056		AllowOverpay :   cfg .allowOverpay ,
@@ -1087,6 +1112,7 @@ func payInvoiceWithAssets(t *testing.T, payer, rfqPeer *HarnessNode,
10871112
10881113type  invoiceConfig  struct  {
10891114	errSubStr  string 
1115+ 	groupKey   []byte 
10901116}
10911117
10921118func  defaultInvoiceConfig () * invoiceConfig  {
@@ -1103,6 +1129,16 @@ func withInvoiceErrSubStr(errSubStr string) invoiceOpt {
11031129	}
11041130}
11051131
1132+ func  withMaybeInvGroupKey (groupMode  bool , groupKey  []byte ) invoiceOpt  {
1133+ 	return  func (c  * invoiceConfig ) {
1134+ 		if  ! groupMode  {
1135+ 			return 
1136+ 		}
1137+ 
1138+ 		c .groupKey  =  groupKey 
1139+ 	}
1140+ }
1141+ 
11061142func  createAssetInvoice (t  * testing.T , dstRfqPeer , dst  * HarnessNode ,
11071143	assetAmount  uint64 , assetID  []byte ,
11081144	opts  ... invoiceOpt ) * lnrpc.AddInvoiceResponse  {
@@ -1112,6 +1148,12 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
11121148		opt (cfg )
11131149	}
11141150
1151+ 	// Nullify assetID if group key is set. RPC methods won't accept both so 
1152+ 	// let's prioritize the group key if set. 
1153+ 	if  len (cfg .groupKey ) >  0  {
1154+ 		assetID  =  []byte {}
1155+ 	}
1156+ 
11151157	ctxb  :=  context .Background ()
11161158	ctxt , cancel  :=  context .WithTimeout (ctxb , defaultTimeout )
11171159	defer  cancel ()
@@ -1126,6 +1168,7 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
11261168
11271169	resp , err  :=  dstTapd .AddInvoice (ctxt , & tchrpc.AddInvoiceRequest {
11281170		AssetId :     assetID ,
1171+ 		GroupKey :    cfg .groupKey ,
11291172		AssetAmount : assetAmount ,
11301173		PeerPubkey :  dstRfqPeer .PubKey [:],
11311174		InvoiceRequest : & lnrpc.Invoice {
@@ -1170,7 +1213,7 @@ func createAssetInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
11701213// individual HTLCs that arrived for it and that they show the correct asset 
11711214// amounts for the given ID when decoded. 
11721215func  assertInvoiceHtlcAssets (t  * testing.T , node  * HarnessNode ,
1173- 	addedInvoice  * lnrpc.AddInvoiceResponse , assetID  []byte ,
1216+ 	addedInvoice  * lnrpc.AddInvoiceResponse , assetID  []byte ,  groupID  [] byte , 
11741217	assetAmount  uint64 ) {
11751218
11761219	ctxb  :=  context .Background ()
@@ -1189,7 +1232,14 @@ func assertInvoiceHtlcAssets(t *testing.T, node *HarnessNode,
11891232
11901233	t .Logf ("Asset invoice: %v" , toProtoJSON (t , invoice ))
11911234
1192- 	targetID  :=  hex .EncodeToString (assetID )
1235+ 	var  targetID  string 
1236+ 	switch  {
1237+ 	case  len (groupID ) >  0 :
1238+ 		targetID  =  hex .EncodeToString (groupID )
1239+ 
1240+ 	case  len (assetID ) >  0 :
1241+ 		targetID  =  hex .EncodeToString (assetID )
1242+ 	}
11931243
11941244	var  totalAssetAmount  uint64 
11951245	for  _ , htlc  :=  range  invoice .Htlcs  {
@@ -1216,7 +1266,7 @@ func assertInvoiceHtlcAssets(t *testing.T, node *HarnessNode,
12161266// individual HTLCs that arrived for it and that they show the correct asset 
12171267// amounts for the given ID when decoded. 
12181268func  assertPaymentHtlcAssets (t  * testing.T , node  * HarnessNode , payHash  []byte ,
1219- 	assetID  []byte , assetAmount  uint64 ) {
1269+ 	assetID  []byte , groupID  [] byte ,  assetAmount  uint64 ) {
12201270
12211271	ctxb  :=  context .Background ()
12221272	ctxt , cancel  :=  context .WithTimeout (ctxb , defaultTimeout )
@@ -1237,7 +1287,14 @@ func assertPaymentHtlcAssets(t *testing.T, node *HarnessNode, payHash []byte,
12371287
12381288	t .Logf ("Asset payment: %v" , toProtoJSON (t , payment ))
12391289
1240- 	targetID  :=  hex .EncodeToString (assetID )
1290+ 	var  targetID  string 
1291+ 	switch  {
1292+ 	case  len (groupID ) >  0 :
1293+ 		targetID  =  hex .EncodeToString (groupID )
1294+ 
1295+ 	case  len (assetID ) >  0 :
1296+ 		targetID  =  hex .EncodeToString (assetID )
1297+ 	}
12411298
12421299	var  totalAssetAmount  uint64 
12431300	for  _ , htlc  :=  range  payment .Htlcs  {
@@ -1267,7 +1324,19 @@ type assetHodlInvoice struct {
12671324}
12681325
12691326func  createAssetHodlInvoice (t  * testing.T , dstRfqPeer , dst  * HarnessNode ,
1270- 	assetAmount  uint64 , assetID  []byte ) assetHodlInvoice  {
1327+ 	assetAmount  uint64 , assetID  []byte ,
1328+ 	opts  ... invoiceOpt ) assetHodlInvoice  {
1329+ 
1330+ 	cfg  :=  defaultInvoiceConfig ()
1331+ 	for  _ , opt  :=  range  opts  {
1332+ 		opt (cfg )
1333+ 	}
1334+ 
1335+ 	// Nullify assetID if group key is set. RPC methods won't accept both so 
1336+ 	// let's prioritize the group key if set. 
1337+ 	if  len (cfg .groupKey ) >  0  {
1338+ 		assetID  =  []byte {}
1339+ 	}
12711340
12721341	ctxb  :=  context .Background ()
12731342	ctxt , cancel  :=  context .WithTimeout (ctxb , defaultTimeout )
@@ -1291,6 +1360,7 @@ func createAssetHodlInvoice(t *testing.T, dstRfqPeer, dst *HarnessNode,
12911360
12921361	resp , err  :=  dstTapd .AddInvoice (ctxt , & tchrpc.AddInvoiceRequest {
12931362		AssetId :     assetID ,
1363+ 		GroupKey :    cfg .groupKey ,
12941364		AssetAmount : assetAmount ,
12951365		PeerPubkey :  dstRfqPeer .PubKey [:],
12961366		InvoiceRequest : & lnrpc.Invoice {
0 commit comments