Documentation ¶
Index ¶
- Constants
- Variables
- func AMPDecoder(r io.Reader, val interface{}, buf *[8]byte, l uint64) error
- func AMPEncoder(w io.Writer, val interface{}, buf *[8]byte) error
- func EncodeBlindedRouteData(data *BlindedRouteData) ([]byte, error)
- func MPPDecoder(r io.Reader, val interface{}, buf *[8]byte, l uint64) error
- func MPPEncoder(w io.Writer, val interface{}, buf *[8]byte) error
- func NewAmtToFwdRecord(amt *uint64) tlv.Record
- func NewBlindingPointRecord(point **btcec.PublicKey) tlv.Record
- func NewEncryptedDataRecord(data *[]byte) tlv.Record
- func NewLockTimeRecord(lockTime *uint32) tlv.Record
- func NewMetadataRecord(metadata *[]byte) tlv.Record
- func NewNextHopIDRecord(cid *uint64) tlv.Record
- func NewTotalAmtMsatBlinded(amt *uint64) tlv.Record
- type AMP
- type BlindedRouteData
- func DecodeBlindedRouteData(r io.Reader) (*BlindedRouteData, error)
- func NewDummyHopRouteData(ourPubKey *btcec.PublicKey, relayInfo PaymentRelayInfo, ...) *BlindedRouteData
- func NewFinalHopBlindedRouteData(constraints *PaymentConstraints, pathID []byte) *BlindedRouteData
- func NewNonFinalBlindedRouteData(chanID lnwire.ShortChannelID, blindingOverride *btcec.PublicKey, ...) *BlindedRouteData
- type CustomSet
- type MPP
- type PaymentConstraints
- type PaymentRelayInfo
Constants ¶
const ( // AmtOnionType is the type used in the onion to reference the amount to // send to the next hop. AmtOnionType tlv.Type = 2 // LockTimeTLV is the type used in the onion to reference the CLTV // value that should be used for the next hop's HTLC. LockTimeOnionType tlv.Type = 4 // NextHopOnionType is the type used in the onion to reference the ID // of the next hop. NextHopOnionType tlv.Type = 6 // EncryptedDataOnionType is the type used to include encrypted data // provided by the receiver in the onion for use in blinded paths. EncryptedDataOnionType tlv.Type = 10 // BlindingPointOnionType is the type used to include receiver provided // ephemeral keys in the onion that are used in blinded paths. BlindingPointOnionType tlv.Type = 12 // MetadataOnionType is the type used in the onion for the payment // metadata. MetadataOnionType tlv.Type = 16 // TotalAmtMsatBlindedType is the type used in the onion for the total // amount field that is included in the final hop for blinded payments. TotalAmtMsatBlindedType tlv.Type = 18 )
const AMPOnionType tlv.Type = 14
AMPOnionType is the type used in the onion to reference the AMP fields: root_share, set_id, and child_index.
const AverageDummyHopPayloadSize = 51
AverageDummyHopPayloadSize is the size of a standard blinded path dummy hop payload. In most cases, this is larger than the other payload types and so to make sure that a sender cannot use this fact to know if a dummy hop is present or not, we'll make sure to always pad all payloads to at least this size.
const ( // CustomTypeStart is the start of the custom tlv type range as defined // in BOLT 01. CustomTypeStart = 65536 )
const ( // KeySendType is the custom record identifier for keysend preimages. KeySendType uint64 = 5482373484 )
const MPPOnionType tlv.Type = 8
MPPOnionType is the type used in the onion to reference the MPP fields: total_amt and payment_addr.
Variables ¶
var MaxAmpPayLoadSize = AMP{ // contains filtered or unexported fields }
MaxAmpPayLoadSize is an AMP Record which when serialized to a tlv record uses the maximum payload size. The `childIndex` is created randomly and is a 4 byte `varint` type so we make sure we use an index which will be encoded in 4 bytes.
Functions ¶
func AMPDecoder ¶
AMPDecoder reads the AMP record from the provided io.Reader.
func AMPEncoder ¶
AMPEncoder writes the AMP record to the provided io.Writer.
func EncodeBlindedRouteData ¶
func EncodeBlindedRouteData(data *BlindedRouteData) ([]byte, error)
EncodeBlindedRouteData encodes the blinded route data provided.
func MPPDecoder ¶
MPPDecoder reads the MPP record to the provided io.Reader.
func MPPEncoder ¶
MPPEncoder writes the MPP record to the provided io.Writer.
func NewAmtToFwdRecord ¶
NewAmtToFwdRecord creates a tlv.Record that encodes the amount_to_forward (type 2) for an onion payload.
func NewBlindingPointRecord ¶
NewBlindingPointRecord creates a tlv.Record that encodes the blinding_point (type 12) record for an onion payload.
func NewEncryptedDataRecord ¶
NewEncryptedDataRecord creates a tlv.Record that encodes the encrypted_data (type 10) record for an onion payload.
func NewLockTimeRecord ¶
NewLockTimeRecord creates a tlv.Record that encodes the outgoing_cltv_value (type 4) for an onion payload.
func NewMetadataRecord ¶
NewMetadataRecord creates a tlv.Record that encodes the metadata (type 10) for an onion payload.
func NewNextHopIDRecord ¶
NewNextHopIDRecord creates a tlv.Record that encodes the short_channel_id (type 6) for an onion payload.
func NewTotalAmtMsatBlinded ¶
NewTotalAmtMsatBlinded creates a tlv.Record that encodes the total_amount_msat for the final an onion payload within a blinded route.
Types ¶
type AMP ¶
type AMP struct {
// contains filtered or unexported fields
}
AMP is a record that encodes the fields necessary for atomic multi-path payments.
func (*AMP) ChildIndex ¶
ChildIndex returns the child index contained in the AMP record.
func (*AMP) PayloadSize ¶
PayloadSize returns the size this record takes up in encoded form.
type BlindedRouteData ¶
type BlindedRouteData struct { // Padding is an optional set of bytes that a recipient can use to pad // the data so that the encrypted recipient data blobs are all the same // length. Padding tlv.OptionalRecordT[tlv.TlvType1, []byte] // ShortChannelID is the channel ID of the next hop. ShortChannelID tlv.OptionalRecordT[tlv.TlvType2, lnwire.ShortChannelID] // NextNodeID is the node ID of the next node on the path. In the // context of blinded path payments, this is used to indicate the // presence of dummy hops that need to be peeled from the onion. NextNodeID tlv.OptionalRecordT[tlv.TlvType4, *btcec.PublicKey] // PathID is a secret set of bytes that the blinded path creator will // set so that they can check the value on decryption to ensure that the // path they created was used for the intended purpose. PathID tlv.OptionalRecordT[tlv.TlvType6, []byte] // NextBlindingOverride is a blinding point that should be switched // in for the next hop. This is used to combine two blinded paths into // one (which primarily is used in onion messaging, but in theory // could be used for payments as well). NextBlindingOverride tlv.OptionalRecordT[tlv.TlvType8, *btcec.PublicKey] // RelayInfo provides the relay parameters for the hop. RelayInfo tlv.OptionalRecordT[tlv.TlvType10, PaymentRelayInfo] // Constraints provides the payment relay constraints for the hop. Constraints tlv.OptionalRecordT[tlv.TlvType12, PaymentConstraints] // Features is the set of features the payment requires. Features tlv.OptionalRecordT[tlv.TlvType14, lnwire.FeatureVector] }
BlindedRouteData contains the information that is included in a blinded route encrypted data blob that is created by the recipient to provide forwarding information.
func DecodeBlindedRouteData ¶
func DecodeBlindedRouteData(r io.Reader) (*BlindedRouteData, error)
DecodeBlindedRouteData decodes the data provided within a blinded route.
func NewDummyHopRouteData ¶
func NewDummyHopRouteData(ourPubKey *btcec.PublicKey, relayInfo PaymentRelayInfo, constraints PaymentConstraints) *BlindedRouteData
NewDummyHopRouteData creates the data that's provided for any hop preceding a dummy hop. The presence of such a payload indicates to the reader that they are the intended recipient and should peel the remainder of the onion.
func NewFinalHopBlindedRouteData ¶
func NewFinalHopBlindedRouteData(constraints *PaymentConstraints, pathID []byte) *BlindedRouteData
NewFinalHopBlindedRouteData creates the data that's provided for the final hop in a blinded route.
func NewNonFinalBlindedRouteData ¶
func NewNonFinalBlindedRouteData(chanID lnwire.ShortChannelID, blindingOverride *btcec.PublicKey, relayInfo PaymentRelayInfo, constraints *PaymentConstraints, features *lnwire.FeatureVector) *BlindedRouteData
NewNonFinalBlindedRouteData creates the data that's provided for hops within a blinded route.
func (*BlindedRouteData) PadBy ¶
func (b *BlindedRouteData) PadBy(n int)
PadBy adds "n" padding bytes to the BlindedRouteData using the Padding field. Callers should be aware that the total payload size will change by more than "n" since the "n" bytes will be prefixed by BigSize type and length fields. Callers may need to call PadBy iteratively until each encrypted data packet is the same size and so each call will overwrite the Padding record. Note that calling PadBy with an n value of 0 will still result in a zero length TLV entry being added.
type MPP ¶
type MPP struct {
// contains filtered or unexported fields
}
MPP is a record that encodes the fields necessary for multi-path payments.
func NewMPP ¶
func NewMPP(total lnwire.MilliSatoshi, addr [32]byte) *MPP
NewMPP generates a new MPP record with the given total and payment address.
func (*MPP) PayloadSize ¶
PayloadSize returns the size this record takes up in encoded form.
func (*MPP) PaymentAddr ¶
PaymentAddr returns the payment address contained in the MPP record.
func (*MPP) TotalMsat ¶
func (r *MPP) TotalMsat() lnwire.MilliSatoshi
TotalMsat returns the total value of an MPP payment in msats.
type PaymentConstraints ¶
type PaymentConstraints struct { // MaxCltvExpiry is the maximum expiry height for the payment. MaxCltvExpiry uint32 // HtlcMinimumMsat is the minimum htlc size for the payment. HtlcMinimumMsat lnwire.MilliSatoshi }
PaymentConstraints is a set of restrictions on a payment.
func (*PaymentConstraints) Record ¶
func (p *PaymentConstraints) Record() tlv.Record
type PaymentRelayInfo ¶
type PaymentRelayInfo struct { // CltvExpiryDelta is the expiry delta for the payment. CltvExpiryDelta uint16 // FeeRate is the fee rate that will be charged per millionth of a // satoshi. FeeRate uint32 // BaseFee is the per-htlc fee charged in milli-satoshis. BaseFee lnwire.MilliSatoshi }
PaymentRelayInfo describes the relay policy for a blinded path.
func (*PaymentRelayInfo) Record ¶
func (i *PaymentRelayInfo) Record() tlv.Record
Record creates a tlv.Record that encodes the payment relay (type 10) type for an encrypted blob payload.