Skip to content

Commit 15582a5

Browse files
authored
Merge pull request #1124 from lightninglabs/rfq-simple-refactor
RFQ cleanup
2 parents 552f838 + 9351be1 commit 15582a5

File tree

4 files changed

+9
-55
lines changed

4 files changed

+9
-55
lines changed

rfqmsg/records.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package rfqmsg
22

33
import (
44
"bytes"
5-
"crypto/sha256"
65
"errors"
76
"fmt"
87
"io"
@@ -391,33 +390,3 @@ func IdDecoder(r io.Reader, val any, buf *[8]byte, l uint64) error {
391390

392391
return tlv.NewTypeForDecodingErr(val, "MessageID", l, idBytesLen)
393392
}
394-
395-
func AssetIdEncoder(w io.Writer, val any, buf *[8]byte) error {
396-
if t, ok := val.(**asset.ID); ok {
397-
id := [sha256.Size]byte(**t)
398-
return tlv.EBytes32(w, &id, buf)
399-
}
400-
401-
return tlv.NewTypeForEncodingErr(val, "assetId")
402-
}
403-
404-
func AssetIdDecoder(r io.Reader, val any, buf *[8]byte, l uint64) error {
405-
const assetIDBytesLen = sha256.Size
406-
407-
if typ, ok := val.(**asset.ID); ok {
408-
var idBytes [assetIDBytesLen]byte
409-
410-
err := tlv.DBytes32(r, &idBytes, buf, assetIDBytesLen)
411-
if err != nil {
412-
return err
413-
}
414-
415-
id := asset.ID(idBytes)
416-
assetId := &id
417-
418-
*typ = assetId
419-
return nil
420-
}
421-
422-
return tlv.NewTypeForDecodingErr(val, "assetId", l, sha256.Size)
423-
}

rfqmsg/reject.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,6 @@ var (
103103
Code: 1,
104104
Msg: "price oracle unavailable",
105105
}
106-
107-
// ErrNoSuitableSellOffer is the error code for when there is no
108-
// suitable sell offer available.
109-
ErrNoSuitableSellOffer = RejectErr{
110-
Code: 2,
111-
Msg: "no suitable sell offer available",
112-
}
113-
114-
// ErrNoSuitableBuyOffer is the error code for when there is no suitable
115-
// buy offer available.
116-
ErrNoSuitableBuyOffer = RejectErr{
117-
Code: 3,
118-
Msg: "no suitable buy offer available",
119-
}
120106
)
121107

122108
const (

rfqmsg/reject_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,20 @@ func TestRejectEncodeDecode(t *testing.T) {
3131
peer: route.Vertex{1, 2, 3},
3232
version: 0,
3333
id: id,
34-
err: ErrNoSuitableSellOffer,
3534
},
3635
{
3736
testName: "all fields populated with basic values",
3837
peer: route.Vertex{1, 2, 3},
3938
version: 5,
4039
id: id,
41-
err: ErrNoSuitableBuyOffer,
40+
},
41+
{
42+
testName: "all fields populated with basic values; " +
43+
"error field populated",
44+
peer: route.Vertex{1, 2, 3},
45+
version: 5,
46+
id: id,
47+
err: ErrPriceOracleUnavailable,
4248
},
4349
}
4450

rfqmsg/sell_accept.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package rfqmsg
22

33
import (
4-
"encoding/binary"
54
"fmt"
65

76
"github.com/lightningnetwork/lnd/lnwire"
@@ -94,13 +93,7 @@ func newSellAcceptFromWireMsg(wireMsg WireMessage,
9493
// ShortChannelId returns the short channel ID associated with the asset sale
9594
// event.
9695
func (q *SellAccept) ShortChannelId() SerialisedScid {
97-
// Given valid RFQ message id, we then define a RFQ short chain id
98-
// (SCID) by taking the last 8 bytes of the RFQ message id and
99-
// interpreting them as a 64-bit integer.
100-
scidBytes := q.ID[24:]
101-
102-
scidInteger := binary.BigEndian.Uint64(scidBytes)
103-
return SerialisedScid(scidInteger)
96+
return q.ID.Scid()
10497
}
10598

10699
// ToWire returns a wire message with a serialized data field.

0 commit comments

Comments
 (0)