Skip to content

Commit

Permalink
rfqmsg: remove redundant asset ID field from accept messages
Browse files Browse the repository at this point in the history
With the request message now included in accept messages, the asset ID
field in accept messages is redundant. This commit removes those
redundant asset ID fields.
  • Loading branch information
ffranr committed Jun 6, 2024
1 parent 48d5267 commit 60c8ed1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 52 deletions.
27 changes: 1 addition & 26 deletions rfqmsg/buy_accept.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package rfqmsg

import (
"bytes"
"crypto/sha256"
"fmt"
"io"

"github.com/lightninglabs/taproot-assets/asset"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route"
"github.com/lightningnetwork/lnd/tlv"
Expand All @@ -20,7 +18,6 @@ const (
TypeBuyAcceptAskPrice tlv.Type = 4
TypeBuyAcceptExpiry tlv.Type = 6
TypeBuyAcceptSignature tlv.Type = 8
TypeBuyAcceptAssetID tlv.Type = 10
)

func TypeRecordBuyAcceptVersion(version *WireMsgDataVersion) tlv.Record {
Expand Down Expand Up @@ -81,15 +78,6 @@ func TypeRecordBuyAcceptSig(sig *[64]byte) tlv.Record {
return tlv.MakePrimitiveRecord(TypeBuyAcceptSignature, sig)
}

func TypeRecordBuyAcceptAssetID(assetID **asset.ID) tlv.Record {
const recordSize = sha256.Size

return tlv.MakeStaticRecord(
TypeBuyAcceptAssetID, assetID, recordSize,
AssetIdEncoder, AssetIdDecoder,
)
}

const (
// latestBuyAcceptVersion is the latest supported buy accept wire
// message data field version.
Expand All @@ -115,28 +103,17 @@ type buyAcceptMsgData struct {

// sig is a signature over the serialized contents of the message.
sig [64]byte

// AssetID is the asset ID of the asset that the accept message is for.
AssetID *asset.ID
}

// encodeRecords provides all TLV records for encoding.
func (q *buyAcceptMsgData) encodeRecords() []tlv.Record {
records := []tlv.Record{
return []tlv.Record{
TypeRecordBuyAcceptVersion(&q.Version),
TypeRecordBuyAcceptID(&q.ID),
TypeRecordBuyAcceptAskPrice(&q.AskPrice),
TypeRecordBuyAcceptExpiry(&q.Expiry),
TypeRecordBuyAcceptSig(&q.sig),
}

if q.AssetID != nil {
records = append(
records, TypeRecordBuyAcceptAssetID(&q.AssetID),
)
}

return records
}

// decodeRecords provides all TLV records for decoding.
Expand All @@ -147,7 +124,6 @@ func (q *buyAcceptMsgData) decodeRecords() []tlv.Record {
TypeRecordBuyAcceptAskPrice(&q.AskPrice),
TypeRecordBuyAcceptExpiry(&q.Expiry),
TypeRecordBuyAcceptSig(&q.sig),
TypeRecordBuyAcceptAssetID(&q.AssetID),
}
}

Expand Down Expand Up @@ -211,7 +187,6 @@ func NewBuyAcceptFromRequest(request BuyRequest, askPrice lnwire.MilliSatoshi,
ID: request.ID,
AskPrice: askPrice,
Expiry: expiry,
AssetID: request.AssetID,
},
}
}
Expand Down
27 changes: 1 addition & 26 deletions rfqmsg/sell_accept.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ package rfqmsg

import (
"bytes"
"crypto/sha256"
"encoding/binary"
"fmt"
"io"

"github.com/lightninglabs/taproot-assets/asset"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing/route"
"github.com/lightningnetwork/lnd/tlv"
Expand All @@ -21,7 +19,6 @@ const (
TypeSellAcceptBidPrice tlv.Type = 4
TypeSellAcceptExpiry tlv.Type = 6
TypeSellAcceptSignature tlv.Type = 8
TypeSellAcceptAssetID tlv.Type = 10
)

func TypeRecordSellAcceptVersion(version *WireMsgDataVersion) tlv.Record {
Expand Down Expand Up @@ -56,15 +53,6 @@ func TypeRecordSellAcceptSig(sig *[64]byte) tlv.Record {
return tlv.MakePrimitiveRecord(TypeSellAcceptSignature, sig)
}

func TypeRecordSellAcceptAssetID(assetID **asset.ID) tlv.Record {
const recordSize = sha256.Size

return tlv.MakeStaticRecord(
TypeSellAcceptAssetID, assetID, recordSize,
AssetIdEncoder, AssetIdDecoder,
)
}

const (
// latestSellAcceptVersion is the latest supported sell accept wire
// message data field version.
Expand All @@ -90,28 +78,17 @@ type sellAcceptMsgData struct {

// sig is a signature over the serialized contents of the message.
sig [64]byte

// AssetID is the asset ID of the asset that the accept message is for.
AssetID *asset.ID
}

// encodeRecords provides all TLV records for encoding.
func (q *sellAcceptMsgData) encodeRecords() []tlv.Record {
records := []tlv.Record{
return []tlv.Record{
TypeRecordSellAcceptVersion(&q.Version),
TypeRecordSellAcceptID(&q.ID),
TypeRecordSellAcceptBidPrice(&q.BidPrice),
TypeRecordSellAcceptExpiry(&q.Expiry),
TypeRecordSellAcceptSig(&q.sig),
}

if q.AssetID != nil {
records = append(
records, TypeRecordSellAcceptAssetID(&q.AssetID),
)
}

return records
}

// decodeRecords provides all TLV records for decoding.
Expand All @@ -122,7 +99,6 @@ func (q *sellAcceptMsgData) decodeRecords() []tlv.Record {
TypeRecordSellAcceptBidPrice(&q.BidPrice),
TypeRecordSellAcceptExpiry(&q.Expiry),
TypeRecordSellAcceptSig(&q.sig),
TypeRecordSellAcceptAssetID(&q.AssetID),
}
}

Expand Down Expand Up @@ -186,7 +162,6 @@ func NewSellAcceptFromRequest(request SellRequest, bidPrice lnwire.MilliSatoshi,
ID: request.ID,
BidPrice: bidPrice,
Expiry: expiry,
AssetID: request.AssetID,
},
}
}
Expand Down

0 comments on commit 60c8ed1

Please sign in to comment.