rfqmsg

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2025 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// MsgTypeRequest is the message type identifier for a quote request
	// message.
	MsgTypeRequest = TapMessageTypeBaseOffset + 0

	// MsgTypeAccept is the message type identifier for a quote accept
	// message.
	MsgTypeAccept = TapMessageTypeBaseOffset + 1

	// MsgTypeReject is the message type identifier for a quote
	// reject message.
	MsgTypeReject = TapMessageTypeBaseOffset + 2
)
View Source
const (
	// DefaultQuoteLifetime is the default duration after which a quote
	// request will expire.
	DefaultQuoteLifetime = 10 * time.Minute
)
View Source
const MaxMessageType = lnwire.MessageType(math.MaxUint16)

MaxMessageType is the maximum supported message type value.

View Source
const (
	// MaxNumOutputs is the maximum number of asset outputs that are allowed
	// in a single record. This mainly affects the maximum number of asset
	// UTXOs that can reside within a single commitment. This number should
	// in practice be very small (probably close to 1), as all outputs must
	// be from the same asset group but from different tranches to be
	// encoded as an individual record.
	MaxNumOutputs = 2048
)
View Source
const TapMessageTypeBaseOffset = 20116 + lnwire.CustomTypeStart

TapMessageTypeBaseOffset is the taproot-assets specific message type identifier base offset. All tap messages will have a type identifier that is greater than this value.

This offset was chosen as the concatenation of the alphabetical index positions of the letters "t" (20), "a" (1), and "p" (16).

Variables

View Source
var (
	// ErrUnknownMessageType is an error returned when an unknown message
	// type is encountered.
	ErrUnknownMessageType = errors.New("unknown message type")

	// MilliSatPerBtc is the number of milli-satoshis in one bitcoin:
	// 100 billion = 100 * (10^9).
	MilliSatPerBtc = rfqmath.FixedPointFromUint64[rfqmath.BigInt](100, 9)
)
View Source
var (
	// ErrUnknownReject is the error code for when the quote is rejected
	// for an unspecified reason.
	ErrUnknownReject = RejectErr{
		Code: 0,
		Msg:  "unknown reject error",
	}

	// ErrPriceOracleUnavailable is the error code for when the price oracle
	// is unavailable.
	ErrPriceOracleUnavailable = RejectErr{
		Code: 1,
		Msg:  "price oracle unavailable",
	}
)
View Source
var (
	// ErrListInvalid is the error that's returned when a list of encoded
	// entries is invalid.
	ErrListInvalid = errors.New("encoded list is invalid")
)

Functions

func HasAssetHTLCCustomRecords added in v0.5.1

func HasAssetHTLCCustomRecords(records lnwire.CustomRecords) bool

HasAssetHTLCCustomRecords returns true if the given custom records contain the custom records that we'd expect an asset HTLC to carry.

func IdDecoder

func IdDecoder(r io.Reader, val any, buf *[8]byte, l uint64) error

func IdEncoder

func IdEncoder(w io.Writer, val any, buf *[8]byte) error

func SomeRfqIDRecord

func SomeRfqIDRecord(id ID) tlv.OptionalRecordT[HtlcRfqIDType, ID]

SomeRfqIDRecord creates an optional record that represents an RFQ ID.

func Sum

func Sum(balances []*AssetBalance) uint64

Sum returns the sum of the amounts of all the asset Balances in the list.

func TlvFixedPointDecoder added in v0.5.0

func TlvFixedPointDecoder(r io.Reader, val any, buf *[8]byte,
	l uint64) error

TlvFixedPointDecoder is a function that can be used to decode a TlvFixedPoint from a reader.

func TlvFixedPointEncoder added in v0.5.0

func TlvFixedPointEncoder(w io.Writer, val any, buf *[8]byte) error

TlvFixedPointEncoder is a function that can be used to encode a TlvFixedPoint to a writer.

func TransferTypeDecoder added in v0.5.0

func TransferTypeDecoder(r io.Reader, val any, buf *[8]byte, l uint64) error

TransferTypeDecoder is a function that can be used to decode a TransferType from a reader.

func TransferTypeEncoder added in v0.5.0

func TransferTypeEncoder(w io.Writer, val any, buf *[8]byte) error

TransferTypeEncoder is a function that can be used to encode a TransferType to a writer.

func WireMsgDataVersionDecoder

func WireMsgDataVersionDecoder(r io.Reader, val any, buf *[8]byte,
	l uint64) error

WireMsgDataVersionDecoder is a function that can be used to decode a WireMsgDataVersion from a reader.

func WireMsgDataVersionEncoder

func WireMsgDataVersionEncoder(w io.Writer, val any, buf *[8]byte) error

WireMsgDataVersionEncoder is a function that can be used to encode a WireMsgDataVersion to a writer.

Types

type AssetBalance

type AssetBalance struct {
	// AssetID is the ID of the asset that this output is associated with.
	AssetID tlv.RecordT[tlv.TlvType0, asset.ID]

	// Amount is the amount of the asset that this output represents.
	Amount tlv.RecordT[tlv.TlvType1, uint64]
}

AssetBalance is a record that represents the amount of an asset that is being transferred or is available to be spent.

func DecodeAssetBalance

func DecodeAssetBalance(blob tlv.Blob) (*AssetBalance, error)

DecodeAssetBalance deserializes a AssetBalance from the given blob.

func NewAssetBalance

func NewAssetBalance(assetID asset.ID, amount uint64) *AssetBalance

NewAssetBalance creates a new AssetBalance record with the given asset ID and amount.

func (*AssetBalance) Bytes

func (a *AssetBalance) Bytes() []byte

Bytes returns the serialized AssetBalance record.

func (*AssetBalance) Decode

func (a *AssetBalance) Decode(r io.Reader) error

Decode deserializes the AssetBalance from the given io.Reader.

func (*AssetBalance) Encode

func (a *AssetBalance) Encode(w io.Writer) error

Encode serializes the AssetBalance to the given io.Writer.

type AssetBalanceListRecord

type AssetBalanceListRecord struct {
	Balances []*AssetBalance
}

AssetBalanceListRecord is a record that represents a list of asset Balances.

func (*AssetBalanceListRecord) Decode

func (l *AssetBalanceListRecord) Decode(r io.Reader) error

Decode deserializes the AssetBalanceListRecord from the given io.Reader.

func (*AssetBalanceListRecord) Encode

func (l *AssetBalanceListRecord) Encode(w io.Writer) error

Encode serializes the AssetBalanceListRecord to the given io.Writer.

func (*AssetBalanceListRecord) Record

func (l *AssetBalanceListRecord) Record() tlv.Record

Record creates a Record out of a AssetBalanceListRecord using the eAssetBalanceList and dAssetBalanceList functions.

NOTE: This is part of the tlv.RecordProducer interface.

func (*AssetBalanceListRecord) Sum

func (l *AssetBalanceListRecord) Sum() uint64

Sum returns the sum of the amounts of all the asset Balances in the list.

type AssetRate added in v0.5.0

type AssetRate struct {
	// Rate defines the exchange rate of asset units to BTC using a
	// fixed-point representation, ensuring precision for fractional asset
	// rates.
	Rate rfqmath.BigIntFixedPoint

	// Expiry indicates the UTC timestamp when this rate expires and should
	// no longer be considered valid.
	Expiry time.Time
}

AssetRate represents the exchange rate of an asset to BTC, encapsulating both the rate in fixed-point format and an expiration timestamp.

These fields are combined in AssetRate because each rate is inherently tied to an expiry, ensuring that the rate's validity is clear and time-limited.

func NewAssetRate added in v0.5.0

func NewAssetRate(rate rfqmath.BigIntFixedPoint, expiry time.Time) AssetRate

NewAssetRate creates a new asset rate.

func (*AssetRate) String added in v0.5.0

func (a *AssetRate) String() string

String returns a human-readable string representation of the asset rate.

type BuyAccept

type BuyAccept struct {
	// Peer is the peer that sent the quote request.
	Peer route.Vertex

	// Request is the quote request message that this message responds to.
	// This field is not included in the wire message.
	Request BuyRequest

	// Version is the version of the message data.
	Version WireMsgDataVersion

	// ID represents the unique identifier of the quote request message that
	// this response is associated with.
	ID ID

	// AssetRate is the accepted asset to BTC rate.
	AssetRate AssetRate
	// contains filtered or unexported fields
}

BuyAccept is a struct that represents a buy quote request accept message.

func NewBuyAcceptFromRequest

func NewBuyAcceptFromRequest(request BuyRequest,
	assetRate AssetRate) *BuyAccept

NewBuyAcceptFromRequest creates a new instance of a quote accept message given a quote request message.

func (*BuyAccept) MsgID

func (q *BuyAccept) MsgID() ID

MsgID returns the quote request session ID.

func (*BuyAccept) MsgPeer

func (q *BuyAccept) MsgPeer() route.Vertex

MsgPeer returns the peer that sent the message.

func (*BuyAccept) ShortChannelId

func (q *BuyAccept) ShortChannelId() SerialisedScid

ShortChannelId returns the short channel ID of the quote accept.

func (*BuyAccept) String

func (q *BuyAccept) String() string

String returns a human-readable string representation of the message.

func (*BuyAccept) ToWire

func (q *BuyAccept) ToWire() (WireMessage, error)

ToWire returns a wire message with a serialized data field.

TODO(ffranr): This method should accept a signer so that we can generate a signature over the message data.

type BuyRequest

type BuyRequest struct {
	// Peer is the peer that sent the quote request.
	Peer route.Vertex

	// Version is the version of the message data.
	Version WireMsgDataVersion

	// ID is the unique identifier of the quote request.
	ID ID

	// AssetSpecifier represents the asset for which this quote request is
	// made. It specifies the particular asset involved in the request.
	AssetSpecifier asset.Specifier

	// AssetMaxAmt represents the maximum asset amount that the responding
	// peer must agree to divest.
	AssetMaxAmt uint64

	// AssetRateHint represents a proposed conversion rate between the
	// subject asset and BTC. This rate is an initial suggestion intended to
	// initiate the RFQ negotiation process and may differ from the final
	// agreed rate.
	AssetRateHint fn.Option[AssetRate]
}

BuyRequest is a struct that represents an asset buy quote request.

Normal usage of a buy request:

  1. Alice, operating a wallet node, wants to receive a Tap asset as payment by issuing a Lightning invoice.
  2. Alice has an asset channel established with Bob's edge node.
  3. Before issuing the invoice, Alice needs to agree on an exchange rate with Bob, who will facilitate the asset transfer.
  4. To obtain the best exchange rate, Alice creates a buy order specifying the desired asset.
  5. Alice's RFQ subsystem processes the buy order and sends buy requests to relevant peers to find the best rate. In this example, Bob is the only available peer.
  6. Once Bob provides a satisfactory quote, Alice accepts it.
  7. Alice issues the Lightning invoice, which Charlie will pay.
  8. Instead of paying Alice directly, Charlie pays Bob.
  9. Bob then forwards the agreed amount of the Tap asset to Alice over their asset channel.

func NewBuyRequest

func NewBuyRequest(peer route.Vertex, assetSpecifier asset.Specifier,
	assetMaxAmt uint64, assetRateHint fn.Option[AssetRate]) (*BuyRequest,
	error)

NewBuyRequest creates a new asset buy quote request.

func NewBuyRequestFromWire added in v0.5.0

func NewBuyRequestFromWire(wireMsg WireMessage,
	msgData requestWireMsgData) (*BuyRequest, error)

NewBuyRequestFromWire instantiates a new instance from a wire message.

func (*BuyRequest) MsgID added in v0.5.0

func (q *BuyRequest) MsgID() ID

MsgID returns the quote request session ID.

func (*BuyRequest) MsgPeer added in v0.5.0

func (q *BuyRequest) MsgPeer() route.Vertex

MsgPeer returns the peer that sent the message.

func (*BuyRequest) String

func (q *BuyRequest) String() string

String returns a human-readable string representation of the message.

func (*BuyRequest) ToWire

func (q *BuyRequest) ToWire() (WireMessage, error)

ToWire returns a wire message with a serialized data field.

func (*BuyRequest) Validate

func (q *BuyRequest) Validate() error

Validate ensures that the buy request is valid.

type Htlc

type Htlc struct {
	// Amounts is a list of asset balances that are changed by the HTLC.
	Amounts tlv.RecordT[HtlcAmountRecordType, AssetBalanceListRecord]

	// RfqID is the RFQ ID that corresponds to the HTLC.
	RfqID tlv.OptionalRecordT[HtlcRfqIDType, ID]
}

Htlc is a record that represents the capacity change related to an in-flight HTLC. This entails all the (asset_id, amount) tuples and other information that we may need to be able to update the TAP portion of a commitment balance.

func DecodeHtlc

func DecodeHtlc(blob tlv.Blob) (*Htlc, error)

DecodeHtlc deserializes a Htlc from the given blob.

func HtlcFromCustomRecords

func HtlcFromCustomRecords(records lnwire.CustomRecords) (*Htlc, error)

HtlcFromCustomRecords creates a new Htlc record from the given custom records.

func NewHtlc

func NewHtlc(amounts []*AssetBalance, rfqID fn.Option[ID]) *Htlc

NewHtlc creates a new Htlc record with the given funded assets.

func (*Htlc) AsJson added in v0.5.0

func (h *Htlc) AsJson() ([]byte, error)

AsJson returns the Htlc record as a JSON blob.

func (*Htlc) Balances

func (h *Htlc) Balances() []*AssetBalance

Balances returns the list of asset Balances that are updated in the Htlc struct.

func (*Htlc) Bytes

func (h *Htlc) Bytes() []byte

Bytes returns the serialized Htlc record.

func (*Htlc) Decode

func (h *Htlc) Decode(r io.Reader) error

Decode deserializes the Htlc from the given io.Reader.

func (*Htlc) Encode

func (h *Htlc) Encode(w io.Writer) error

Encode serializes the Htlc to the given io.Writer.

func (*Htlc) Records

func (h *Htlc) Records() []tlv.Record

Records returns the records that make up the Htlc.

func (*Htlc) SumAssetBalance added in v0.5.0

func (h *Htlc) SumAssetBalance(assetSpecifier asset.Specifier) (rfqmath.BigInt,
	error)

SumAssetBalance returns the sum of the asset balances for the given asset.

func (*Htlc) ToCustomRecords added in v0.5.0

func (h *Htlc) ToCustomRecords() (lnwire.CustomRecords, error)

ToCustomRecords converts the Htlc record to a map of custom records.

type HtlcAmountRecordType

type HtlcAmountRecordType = tlv.TlvType65536

HtlcAmountRecordType is a type alias for the TLV type that is used to encode an asset ID and amount list within the custom records of an HTLC record on the wire.

type HtlcRfqIDType

type HtlcRfqIDType = tlv.TlvType65538

HtlcRfqIDType is the type alias for the TLV type that is used to encode an RFQ id within the custom records of an HTLC record on the wire.

type ID

type ID [32]byte

ID is the identifier for a RFQ message. A new ID _MUST_ be created using the NewID constructor to make sure it can be transformed into a valid SCID alias.

func NewID added in v0.5.0

func NewID() (ID, error)

NewID generates a new random ID that can be transformed into a valid SCID alias that is in the allowed range for lnd.

func (*ID) Record

func (id *ID) Record() tlv.Record

Record returns a TLV record that can be used to encode/decode an ID to/from a TLV stream.

NOTE: This is part of the tlv.RecordProducer interface.

func (*ID) Scid

func (id *ID) Scid() SerialisedScid

Scid returns the short channel id (SCID) of the RFQ message.

func (*ID) String

func (id *ID) String() string

String returns the string representation of the ID.

type IncomingMsg

type IncomingMsg interface {
	// MsgPeer returns the peer that sent the message.
	MsgPeer() route.Vertex

	// MsgID returns the quote request session ID.
	MsgID() ID

	// String returns a human-readable string representation of the message.
	String() string
}

IncomingMsg is an interface that represents an inbound wire message that has been received from a peer.

func NewIncomingAcceptFromWire

func NewIncomingAcceptFromWire(wireMsg WireMessage,
	sessionLookup SessionLookup) (IncomingMsg, error)

NewIncomingAcceptFromWire creates a new quote accept message from an incoming wire message.

This is an incoming accept message. An incoming buy accept message indicates that our peer accepts our buy request, meaning they are willing to sell the asset to us. Conversely, an incoming sell accept message indicates that our peer accepts our sell request, meaning they are willing to buy the asset from us.

func NewIncomingMsgFromWire

func NewIncomingMsgFromWire(wireMsg WireMessage,
	sessionLookup SessionLookup) (IncomingMsg, error)

NewIncomingMsgFromWire creates a new RFQ message from a wire message.

func NewIncomingRequestFromWire

func NewIncomingRequestFromWire(wireMsg WireMessage) (IncomingMsg, error)

NewIncomingRequestFromWire creates a new request message from an incoming wire message.

Note that this is an incoming request. Which means that a buy request is a request from our peer to buy the asset from us, and a sell request is a request from out peer to sell the asset to us.

type JsonAssetBalance

type JsonAssetBalance struct {
	AssetID       string `json:"asset_id"`
	Name          string `json:"name"`
	LocalBalance  uint64 `json:"local_balance"`
	RemoteBalance uint64 `json:"remote_balance"`
}

JsonAssetBalance is a struct that represents the balance of a single asset ID within a channel.

type JsonAssetChanInfo

type JsonAssetChanInfo struct {
	AssetInfo     JsonAssetUtxo `json:"asset_utxo"`
	Capacity      uint64        `json:"capacity"`
	LocalBalance  uint64        `json:"local_balance"`
	RemoteBalance uint64        `json:"remote_balance"`
}

JsonAssetChanInfo is a struct that represents the channel information of a single asset within a channel.

type JsonAssetChannel

type JsonAssetChannel struct {
	Assets []JsonAssetChanInfo `json:"assets"`
}

JsonAssetChannel is a struct that represents the channel information of all assets within a channel.

type JsonAssetChannelBalances

type JsonAssetChannelBalances struct {
	OpenChannels    map[string]*JsonAssetBalance `json:"open_channels"`
	PendingChannels map[string]*JsonAssetBalance `json:"pending_channels"`
}

JsonAssetChannelBalances is a struct that represents the balance information of all assets within open and pending channels.

type JsonAssetGenesis

type JsonAssetGenesis struct {
	GenesisPoint string `json:"genesis_point"`
	Name         string `json:"name"`
	MetaHash     string `json:"meta_hash"`
	AssetID      string `json:"asset_id"`
}

JsonAssetGenesis is a struct that represents the genesis information of an asset.

type JsonAssetUtxo

type JsonAssetUtxo struct {
	Version        int64            `json:"version"`
	AssetGenesis   JsonAssetGenesis `json:"asset_genesis"`
	Amount         uint64           `json:"amount"`
	ScriptKey      string           `json:"script_key"`
	DecimalDisplay uint8            `json:"decimal_display"`
}

JsonAssetUtxo is a struct that represents the UTXO information of an asset within a channel.

type JsonCloseOutput

type JsonCloseOutput struct {
	BtcInternalKey   string            `json:"btc_internal_key"`
	AssetInternalKey string            `json:"asset_internal_key"`
	ScriptKeys       map[string]string `json:"script_keys"`
}

JsonCloseOutput is a struct that represents the additional co-op close output information of asset channels.

type JsonHtlc added in v0.5.0

type JsonHtlc struct {
	Balances []*JsonHtlcBalance `json:"balances"`
	RfqID    string             `json:"rfq_id"`
}

JsonHtlc is a struct that represents the asset information that can be transferred via an HTLC.

type JsonHtlcBalance added in v0.5.0

type JsonHtlcBalance struct {
	AssetID string `json:"asset_id"`
	Amount  uint64 `json:"amount"`
}

JsonHtlcBalance is a struct that represents the balance of a single asset HTLC.

type OutgoingMsg

type OutgoingMsg interface {
	// String returns a human-readable string representation of the message.
	String() string

	// ToWire returns a wire message with a serialized data field.
	ToWire() (WireMessage, error)
}

OutgoingMsg is an interface that represents an outbound wire message that can be sent to a peer.

type QuoteResponse

type QuoteResponse interface {
	// MsgPeer returns the peer that sent the message.
	MsgPeer() route.Vertex

	// MsgID returns the quote request session ID.
	MsgID() ID

	// String returns a human-readable string representation of the message.
	String() string
}

QuoteResponse defines an interface for handling incoming peer messages that serve as responses to quote requests.

type Reject

type Reject struct {
	// Peer is the peer that sent the quote request.
	Peer route.Vertex
	// contains filtered or unexported fields
}

Reject is a struct that represents a quote reject message.

func NewQuoteRejectFromWireMsg

func NewQuoteRejectFromWireMsg(wireMsg WireMessage) (*Reject, error)

NewQuoteRejectFromWireMsg instantiates a new instance from a wire message.

func NewReject

func NewReject(peer route.Vertex, requestId ID,
	rejectErr RejectErr) *Reject

NewReject creates a new instance of a quote reject message.

func (*Reject) Bytes

func (q *Reject) Bytes() ([]byte, error)

Bytes encodes the structure into a TLV stream and returns the bytes.

func (*Reject) Decode

func (q *Reject) Decode(r io.Reader) error

Decode decodes the structure from a TLV stream.

func (*Reject) Encode

func (q *Reject) Encode(writer io.Writer) error

Encode encodes the structure into a TLV stream.

func (*Reject) MsgID added in v0.5.0

func (q *Reject) MsgID() ID

MsgID returns the quote request session ID.

func (*Reject) MsgPeer added in v0.5.0

func (q *Reject) MsgPeer() route.Vertex

MsgPeer returns the peer that sent the message.

func (*Reject) String

func (q *Reject) String() string

String returns a human-readable string representation of the message.

func (*Reject) ToWire

func (q *Reject) ToWire() (WireMessage, error)

ToWire returns a wire message with a serialized data field.

type RejectErr

type RejectErr struct {
	// Code is the error code that provides the reason for the rejection.
	Code uint8

	// Msg is the error message that provides the reason for the rejection.
	Msg string
}

RejectErr is a struct that represents the error code and message of a quote reject message.

func (*RejectErr) Record added in v0.5.0

func (v *RejectErr) Record() tlv.Record

Record returns a TLV record that can be used to encode/decode a RejectErr to/from a TLV stream.

type SellAccept

type SellAccept struct {
	// Peer is the peer that sent the quote request.
	Peer route.Vertex

	// Request is the quote request message that this message responds to.
	// This field is not included in the wire message.
	Request SellRequest

	// Version is the version of the message data.
	Version WireMsgDataVersion

	// ID represents the unique identifier of the asset sell quote request
	// message that this response is associated with.
	ID ID

	// AssetRate is the accepted asset to BTC rate.
	AssetRate AssetRate
	// contains filtered or unexported fields
}

SellAccept is a struct that represents a sell quote request accept message.

func NewSellAcceptFromRequest

func NewSellAcceptFromRequest(request SellRequest,
	assetRate AssetRate) *SellAccept

NewSellAcceptFromRequest creates a new instance of an asset sell quote accept message given an asset sell quote request message.

func (*SellAccept) MsgID

func (q *SellAccept) MsgID() ID

MsgID returns the quote request session ID.

func (*SellAccept) MsgPeer

func (q *SellAccept) MsgPeer() route.Vertex

MsgPeer returns the peer that sent the message.

func (*SellAccept) ShortChannelId

func (q *SellAccept) ShortChannelId() SerialisedScid

ShortChannelId returns the short channel ID associated with the asset sale event.

func (*SellAccept) String

func (q *SellAccept) String() string

String returns a human-readable string representation of the message.

func (*SellAccept) ToWire

func (q *SellAccept) ToWire() (WireMessage, error)

ToWire returns a wire message with a serialized data field.

TODO(ffranr): This method should accept a signer so that we can generate a signature over the message data.

type SellRequest

type SellRequest struct {
	// Peer is the peer that sent the quote request.
	Peer route.Vertex

	// Version is the version of the message data.
	Version WireMsgDataVersion

	// ID is the unique identifier of the quote request.
	ID ID

	// AssetSpecifier represents the asset for which this quote request is
	// made. It specifies the particular asset involved in the request.
	AssetSpecifier asset.Specifier

	// PaymentMaxAmt is the maximum msat amount that the responding peer
	// must agree to pay.
	PaymentMaxAmt lnwire.MilliSatoshi

	// AssetRateHint represents a proposed conversion rate between the
	// subject asset and BTC. This rate is an initial suggestion intended to
	// initiate the RFQ negotiation process and may differ from the final
	// agreed rate.
	AssetRateHint fn.Option[AssetRate]
}

SellRequest is a struct that represents an asset sell quote request.

Normal usage of a sell request:

  1. Alice creates a Lightning invoice for Bob to pay.
  2. Bob wants to pay the invoice using a Tap asset. To do so, Bob pays an edge node with a Tap asset, and the edge node forwards the payment to the network to settle Alice's invoice. Bob submits a SellOrder to his local RFQ service.
  3. The RFQ service converts the SellOrder into one or more SellRequests. These requests are sent to Charlie (the edge node), who shares a relevant Tap asset channel with Bob and can forward payments to settle Alice's invoice.
  4. Charlie responds with a quote that satisfies Bob.
  5. Bob transfers the appropriate Tap asset amount to Charlie via their shared Tap asset channel, and Charlie forwards the corresponding amount to Alice to settle the Lightning invoice.

func NewSellRequest

func NewSellRequest(peer route.Vertex, assetSpecifier asset.Specifier,
	paymentMaxAmt lnwire.MilliSatoshi,
	assetRateHint fn.Option[AssetRate]) (*SellRequest, error)

NewSellRequest creates a new asset sell quote request.

func NewSellRequestFromWire added in v0.5.0

func NewSellRequestFromWire(wireMsg WireMessage,
	msgData requestWireMsgData) (*SellRequest, error)

NewSellRequestFromWire instantiates a new instance from a wire message.

func (*SellRequest) MsgID added in v0.5.0

func (q *SellRequest) MsgID() ID

MsgID returns the quote request session ID.

func (*SellRequest) MsgPeer added in v0.5.0

func (q *SellRequest) MsgPeer() route.Vertex

MsgPeer returns the peer that sent the message.

func (*SellRequest) String

func (q *SellRequest) String() string

String returns a human-readable string representation of the message.

func (*SellRequest) ToWire

func (q *SellRequest) ToWire() (WireMessage, error)

ToWire returns a wire message with a serialized data field.

func (*SellRequest) Validate

func (q *SellRequest) Validate() error

Validate ensures that the quote request is valid.

type SerialisedScid

type SerialisedScid uint64

SerialisedScid is a serialised short channel id (SCID).

type SessionLookup added in v0.5.0

type SessionLookup func(id ID) (OutgoingMsg, bool)

SessionLookup is a function that can be used to look up a session quote request message given a session ID.

type TlvFixedPoint added in v0.5.0

type TlvFixedPoint struct {
	// contains filtered or unexported fields
}

TlvFixedPoint is a fixed-point that can be TLV encode/decode.

func NewTlvFixedPointFromBigInt added in v0.5.0

func NewTlvFixedPointFromBigInt(fp rfqmath.BigIntFixedPoint) TlvFixedPoint

NewTlvFixedPointFromBigInt creates a new fixed-point given a BigInt fixed-point.

func NewTlvFixedPointFromUint64 added in v0.5.0

func NewTlvFixedPointFromUint64(coefficient uint64, scale uint8) TlvFixedPoint

NewTlvFixedPointFromUint64 creates a new fixed point record given a `uint64` coefficient and scale.

func (*TlvFixedPoint) IntoBigIntFixedPoint added in v0.5.0

func (f *TlvFixedPoint) IntoBigIntFixedPoint() rfqmath.BigIntFixedPoint

IntoBigIntFixedPoint converts the TlvFixedPoint to a BigIntFixedPoint.

func (*TlvFixedPoint) Record added in v0.5.0

func (f *TlvFixedPoint) Record() tlv.Record

Record returns a TLV record that can be used to encode/decode an ID to/from a TLV stream.

NOTE: This is part of the tlv.RecordProducer interface.

type TransferType added in v0.5.0

type TransferType uint8

TransferType defines the type of transaction which will be performed if the quote request leads to an accepted agreement.

const (
	// UnspecifiedTransferType represents an undefined or transfer type.
	UnspecifiedTransferType TransferType = 0

	// PayInvoiceTransferType indicates that the requesting peer wants to
	// pay a Lightning Network invoice using a taproot asset.
	PayInvoiceTransferType TransferType = 1

	// RecvPaymentTransferType indicates that the requesting peer wants
	// to receive taproot asset funds linked to a Lightning Network invoice.
	RecvPaymentTransferType TransferType = 2
)

func (*TransferType) Record added in v0.5.0

func (t *TransferType) Record() tlv.Record

Record returns a TLV record that can be used to encode/decode a transfer type to/from a TLV stream.

NOTE: This is part of the tlv.RecordProducer interface.

type WireMessage

type WireMessage struct {
	// Peer is the origin/destination peer for this message.
	Peer route.Vertex

	// MsgType is the protocol message type number.
	MsgType lnwire.MessageType

	// Data is the data exchanged.
	Data []byte
}

WireMessage is a struct that represents a general wire message.

type WireMsgDataVersion

type WireMsgDataVersion uint8

WireMsgDataVersion specifies the version of the contents within a wire message data field.

const (
	// V0 represents version 0 of the contents in a wire message data field.
	V0 WireMsgDataVersion = 0

	// V1 represents version 1 of the contents in a wire message data field.
	V1 WireMsgDataVersion = 1
)

func (*WireMsgDataVersion) Record

func (v *WireMsgDataVersion) Record() tlv.Record

Record returns a TLV record that can be used to encode/decode a WireMsgDataVersion to/from a TLV stream.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL