Documentation
¶
Index ¶
- Constants
- 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 MPPDecoder(r io.Reader, val interface{}, buf *[8]byte, l uint64) error
- func MPPEncoder(w io.Writer, val interface{}, buf *[8]byte) error
- func MigrateMCRouteSerialisation(tx kvdb.RwTx) error
- func NewBlindingPointRecord(point **btcec.PublicKey) tlv.Record
- func NewEncryptedDataRecord(data *[]byte) tlv.Record
- func NewMetadataRecord(metadata *[]byte) tlv.Record
- func NewTotalAmtMsatBlinded(amt *uint64) tlv.Record
- func ReadElement(r io.Reader, element interface{}) error
- func ReadElements(r io.Reader, elements ...interface{}) error
- func SerializeRoute(w io.Writer, r Route) error
- func UseLogger(logger btclog.Logger)
- func WriteElement(w io.Writer, element interface{}) error
- func WriteElements(w io.Writer, elements ...interface{}) error
- type AMP
- type Hop
- type MPP
- type Route
- type UnknownElementType
- type Vertex
Constants ¶
const ( // 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 ( // MPPOnionType is the type used in the onion to reference the MPP // fields: total_amt and payment_addr. MPPOnionType tlv.Type = 8 // AMPOnionType is the type used in the onion to reference the AMP // fields: root_share, set_id, and child_index. AMPOnionType tlv.Type = 14 )
const VertexSize = 33
VertexSize is the size of the array to store a vertex.
Variables ¶
This section is empty.
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 MPPDecoder ¶
MPPDecoder reads the MPP record to the provided io.Reader.
func MPPEncoder ¶
MPPEncoder writes the MPP record to the provided io.Writer.
func MigrateMCRouteSerialisation ¶
MigrateMCRouteSerialisation reads all the mission control store entries and re-serializes them using a minimal route serialisation so that only the parts of the route that are actually required for mission control are persisted.
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 NewMetadataRecord ¶
NewMetadataRecord creates a tlv.Record that encodes the metadata (type 10) 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.
func ReadElement ¶
ReadElement is a one-stop utility function to deserialize any datastructure encoded using the serialization format of the database.
func ReadElements ¶
ReadElements deserializes a variable number of elements into the passed io.Reader, with each element being deserialized according to the ReadElement function.
func SerializeRoute ¶
SerializeRoute serializes a route.
func WriteElement ¶
WriteElement is a one-stop shop to write the big endian representation of any element which is to be serialized for storage on disk. The passed io.Writer should be backed by an appropriately sized byte slice, or be able to dynamically expand to accommodate additional data.
func WriteElements ¶
WriteElements is writes each element in the elements slice to the passed io.Writer using WriteElement.
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) PayloadSize ¶
PayloadSize returns the size this record takes up in encoded form.
type Hop ¶
type Hop struct {
// PubKeyBytes is the raw bytes of the public key of the target node.
PubKeyBytes Vertex
// ChannelID is the unique channel ID for the channel. The first 3
// bytes are the block height, the next 3 the index within the block,
// and the last 2 bytes are the output index for the channel.
ChannelID uint64
// OutgoingTimeLock is the timelock value that should be used when
// crafting the _outgoing_ HTLC from this hop.
OutgoingTimeLock uint32
// AmtToForward is the amount that this hop will forward to the next
// hop. This value is less than the value that the incoming HTLC
// carries as a fee will be subtracted by the hop.
AmtToForward lnwire.MilliSatoshi
// MPP encapsulates the data required for option_mpp. This field should
// only be set for the final hop.
MPP *MPP
// AMP encapsulates the data required for option_amp. This field should
// only be set for the final hop.
AMP *AMP
// CustomRecords if non-nil are a set of additional TLV records that
// should be included in the forwarding instructions for this node.
CustomRecords lnwire.CustomRecords
// LegacyPayload if true, then this signals that this node doesn't
// understand the new TLV payload, so we must instead use the legacy
// payload.
//
// NOTE: we should no longer ever create a Hop with Legacy set to true.
// The only reason we are keeping this member is that it could be the
// case that we have serialised hops persisted to disk where
// LegacyPayload is true.
LegacyPayload bool
// Metadata is additional data that is sent along with the payment to
// the payee.
Metadata []byte
// EncryptedData is an encrypted data blob includes for hops that are
// part of a blinded route.
EncryptedData []byte
// BlindingPoint is an ephemeral public key used by introduction nodes
// in blinded routes to unblind their portion of the route and pass on
// the next ephemeral key to the next blinded node to do the same.
BlindingPoint *btcec.PublicKey
// TotalAmtMsat is the total amount for a blinded payment, potentially
// spread over more than one HTLC. This field should only be set for
// the final hop in a blinded path.
TotalAmtMsat lnwire.MilliSatoshi
}
Hop represents an intermediate or final node of the route. This naming is in line with the definition given in BOLT #4: Onion Routing Protocol. The struct houses the channel along which this hop can be reached and the values necessary to create the HTLC that needs to be sent to the next hop. It is also used to encode the per-hop payload included within the Sphinx packet.
type MPP ¶
type MPP struct {
// contains filtered or unexported fields
}
MPP is a record that encodes the fields necessary for multi-path payments.
type Route ¶
type Route struct {
// TotalTimeLock is the cumulative (final) time lock across the entire
// route. This is the CLTV value that should be extended to the first
// hop in the route. All other hops will decrement the time-lock as
// advertised, leaving enough time for all hops to wait for or present
// the payment preimage to complete the payment.
TotalTimeLock uint32
// TotalAmount is the total amount of funds required to complete a
// payment over this route. This value includes the cumulative fees at
// each hop. As a result, the HTLC extended to the first-hop in the
// route will need to have at least this many satoshis, otherwise the
// route will fail at an intermediate node due to an insufficient
// amount of fees.
TotalAmount lnwire.MilliSatoshi
// SourcePubKey is the pubkey of the node where this route originates
// from.
SourcePubKey Vertex
// Hops contains details concerning the specific forwarding details at
// each hop.
Hops []*Hop
// FirstHopAmount is the amount that should actually be sent to the
// first hop in the route. This is only different from TotalAmount above
// for custom channels where the on-chain amount doesn't necessarily
// reflect all the value of an outgoing payment.
FirstHopAmount tlv.RecordT[
tlv.TlvType0, tlv.BigSizeT[lnwire.MilliSatoshi],
]
// FirstHopWireCustomRecords is a set of custom records that should be
// included in the wire message sent to the first hop. This is only set
// on custom channels and is used to include additional information
// about the actual value of the payment.
//
// NOTE: Since these records already represent TLV records, and we
// enforce them to be in the custom range (e.g. >= 65536), we don't use
// another parent record type here. Instead, when serializing the Route
// we merge the TLV records together with the custom records and encode
// everything as a single TLV stream.
FirstHopWireCustomRecords lnwire.CustomRecords
}
Route represents a path through the channel graph which runs over one or more channels in succession. This struct carries all the information required to craft the Sphinx onion packet, and send the payment along the first hop in the path. A route is only selected as valid if all the channels have sufficient capacity to carry the initial payment amount after fees are accounted for.
type UnknownElementType ¶
type UnknownElementType struct {
// contains filtered or unexported fields
}
UnknownElementType is an error returned when the codec is unable to encode or decode a particular type.
func (UnknownElementType) Error ¶
func (e UnknownElementType) Error() string
Error returns the name of the method that encountered the error, as well as the type that was unsupported.