Skip to content

Commit f55bd62

Browse files
committed
rfqmsg: request validation accepts group key
Previously our sell & buy request message validators would consider the message invalid if the included specifier didn't set an ID. Now we want to support group keys, so having either a group key or ID defined is fine.
1 parent 8b91b0b commit f55bd62

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

rfqmsg/buy_request.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,9 @@ func NewBuyRequestFromWire(wireMsg WireMessage,
159159
// Validate ensures that the buy request is valid.
160160
func (q *BuyRequest) Validate() error {
161161
// Ensure that the asset specifier is set.
162-
//
163-
// TODO(ffranr): For now, the asset ID must be set. We do not currently
164-
// support group keys.
165-
if !q.AssetSpecifier.HasId() {
166-
return fmt.Errorf("asset id not specified in BuyRequest")
162+
err := q.AssetSpecifier.AssertNotEmpty()
163+
if err != nil {
164+
return err
167165
}
168166

169167
// Ensure that the message version is supported.
@@ -173,7 +171,7 @@ func (q *BuyRequest) Validate() error {
173171
}
174172

175173
// Ensure that the suggested asset rate has not expired.
176-
err := fn.MapOptionZ(q.AssetRateHint, func(rate AssetRate) error {
174+
err = fn.MapOptionZ(q.AssetRateHint, func(rate AssetRate) error {
177175
if rate.Expiry.Before(time.Now()) {
178176
return fmt.Errorf("suggested asset rate has expired")
179177
}

rfqmsg/sell_request.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,10 @@ func NewSellRequestFromWire(wireMsg WireMessage,
152152

153153
// Validate ensures that the quote request is valid.
154154
func (q *SellRequest) Validate() error {
155-
// Ensure that the asset specifier is set.
156-
//
157-
// TODO(ffranr): For now, the asset ID must be set. We do not currently
158-
// support group keys.
159-
if !q.AssetSpecifier.HasId() {
160-
return fmt.Errorf("asset id not specified in SellRequest")
155+
// Ensure that the asset specifier is not empty.
156+
err := q.AssetSpecifier.AssertNotEmpty()
157+
if err != nil {
158+
return err
161159
}
162160

163161
// Ensure that the message version is supported.

0 commit comments

Comments
 (0)