@@ -7684,18 +7684,31 @@ func checkOverpayment(quote *rfqrpc.PeerAcceptedSellQuote,
7684
7684
func (r * rpcServer ) AddInvoice (ctx context.Context ,
7685
7685
req * tchrpc.AddInvoiceRequest ) (* tchrpc.AddInvoiceResponse , error ) {
7686
7686
7687
+ if len (req .AssetId ) > 0 && len (req .GroupKey ) > 0 {
7688
+ return nil , fmt .Errorf ("cannot set both asset id and group key" )
7689
+ }
7690
+
7687
7691
if req .InvoiceRequest == nil {
7688
7692
return nil , fmt .Errorf ("invoice request must be specified" )
7689
7693
}
7690
7694
iReq := req .InvoiceRequest
7691
7695
7692
- // Do some preliminary checks on the asset ID and make sure we have any
7693
- // balance for that asset.
7694
- if len (req .AssetId ) != sha256 .Size {
7695
- return nil , fmt .Errorf ("asset ID must be 32 bytes" )
7696
+ var specifier asset.Specifier
7697
+
7698
+ assetID , groupKey , err := parseAssetSpecifier (
7699
+ req .AssetId , "" , req .GroupKey , "" ,
7700
+ )
7701
+ if err != nil {
7702
+ return nil , err
7703
+ }
7704
+
7705
+ switch {
7706
+ case assetID != nil :
7707
+ specifier = asset .NewSpecifierFromId (* assetID )
7708
+
7709
+ case groupKey != nil :
7710
+ specifier = asset .NewSpecifierFromGroupKey (* groupKey )
7696
7711
}
7697
- var assetID asset.ID
7698
- copy (assetID [:], req .AssetId )
7699
7712
7700
7713
// The peer public key is optional if there is only a single asset
7701
7714
// channel.
@@ -7710,8 +7723,6 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
7710
7723
peerPubKey = & parsedKey
7711
7724
}
7712
7725
7713
- specifier := asset .NewSpecifierFromId (assetID )
7714
-
7715
7726
// We can now query the asset channels we have.
7716
7727
assetChan , err := r .rfqChannel (
7717
7728
ctx , specifier , peerPubKey , ReceiveIntention ,
@@ -7733,15 +7744,13 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
7733
7744
time .Duration (expirySeconds ) * time .Second ,
7734
7745
)
7735
7746
7747
+ rpcSpecifier := marshalAssetSpecifier (specifier )
7748
+
7736
7749
resp , err := r .AddAssetBuyOrder (ctx , & rfqrpc.AddAssetBuyOrderRequest {
7737
- AssetSpecifier : & rfqrpc.AssetSpecifier {
7738
- Id : & rfqrpc.AssetSpecifier_AssetId {
7739
- AssetId : assetID [:],
7740
- },
7741
- },
7742
- AssetMaxAmt : req .AssetAmount ,
7743
- Expiry : uint64 (expiryTimestamp .Unix ()),
7744
- PeerPubKey : peerPubKey [:],
7750
+ AssetSpecifier : & rpcSpecifier ,
7751
+ AssetMaxAmt : req .AssetAmount ,
7752
+ Expiry : uint64 (expiryTimestamp .Unix ()),
7753
+ PeerPubKey : peerPubKey [:],
7745
7754
TimeoutSeconds : uint32 (
7746
7755
rfq .DefaultTimeout .Seconds (),
7747
7756
),
0 commit comments