@@ -90,6 +90,63 @@ func (id *ID) Record() tlv.Record {
9090 return tlv .MakeStaticRecord (0 , id , recordSize , IdEncoder , IdDecoder )
9191}
9292
93+ // TransferType defines the type of transaction which will be performed if the
94+ // quote request leads to an accepted agreement.
95+ type TransferType uint8
96+
97+ const (
98+ // UnspecifiedTransferType represents an undefined or transfer type.
99+ UnspecifiedTransferType TransferType = 0
100+
101+ // PayInvoiceTransferType indicates that the requesting peer wants to
102+ // pay a Lightning Network invoice using a taproot asset.
103+ PayInvoiceTransferType TransferType = 1
104+
105+ // RecvPaymentTransferType indicates that the requesting peer wants
106+ // to receive taproot asset funds linked to a Lightning Network invoice.
107+ RecvPaymentTransferType TransferType = 2
108+ )
109+
110+ // Record returns a TLV record that can be used to encode/decode a transfer type
111+ // to/from a TLV stream.
112+ //
113+ // NOTE: This is part of the tlv.RecordProducer interface.
114+ func (t * TransferType ) Record () tlv.Record {
115+ // Note that we set the type here as zero, as when used with a
116+ // tlv.RecordT, the type param will be used as the type.
117+ return tlv .MakeStaticRecord (
118+ 0 , t , 1 , TransferTypeEncoder , TransferTypeDecoder ,
119+ )
120+ }
121+
122+ // TransferTypeEncoder is a function that can be used to encode a TransferType
123+ // to a writer.
124+ func TransferTypeEncoder (w io.Writer , val any , buf * [8 ]byte ) error {
125+ if transferType , ok := val .(* TransferType ); ok {
126+ transferTypeInt := uint8 (* transferType )
127+ return tlv .EUint8 (w , & transferTypeInt , buf )
128+ }
129+
130+ return tlv .NewTypeForEncodingErr (val , "TransferType" )
131+ }
132+
133+ // TransferTypeDecoder is a function that can be used to decode a TransferType
134+ // from a reader.
135+ func TransferTypeDecoder (r io.Reader , val any , buf * [8 ]byte , l uint64 ) error {
136+ if transferType , ok := val .(* TransferType ); ok {
137+ var transferTypeInt uint8
138+ err := tlv .DUint8 (r , & transferTypeInt , buf , l )
139+ if err != nil {
140+ return err
141+ }
142+
143+ * transferType = TransferType (transferTypeInt )
144+ return nil
145+ }
146+
147+ return tlv .NewTypeForDecodingErr (val , "TransferType" , l , 8 )
148+ }
149+
93150// AssetRate represents the exchange rate of an asset to BTC, encapsulating
94151// both the rate in fixed-point format and an expiration timestamp.
95152//
0 commit comments