migration32

package
v0.19.2-beta Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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
)
View Source
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
)
View Source
const VertexSize = 33

VertexSize is the size of the array to store a vertex.

Variables

This section is empty.

Functions

func AMPDecoder

func AMPDecoder(r io.Reader, val interface{}, buf *[8]byte, l uint64) error

AMPDecoder reads the AMP record from the provided io.Reader.

func AMPEncoder

func AMPEncoder(w io.Writer, val interface{}, buf *[8]byte) error

AMPEncoder writes the AMP record to the provided io.Writer.

func MPPDecoder

func MPPDecoder(r io.Reader, val interface{}, buf *[8]byte, l uint64) error

MPPDecoder reads the MPP record to the provided io.Reader.

func MPPEncoder

func MPPEncoder(w io.Writer, val interface{}, buf *[8]byte) error

MPPEncoder writes the MPP record to the provided io.Writer.

func MigrateMCRouteSerialisation

func MigrateMCRouteSerialisation(tx kvdb.RwTx) error

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

func NewBlindingPointRecord(point **btcec.PublicKey) tlv.Record

NewBlindingPointRecord creates a tlv.Record that encodes the blinding_point (type 12) record for an onion payload.

func NewEncryptedDataRecord

func NewEncryptedDataRecord(data *[]byte) tlv.Record

NewEncryptedDataRecord creates a tlv.Record that encodes the encrypted_data (type 10) record for an onion payload.

func NewMetadataRecord

func NewMetadataRecord(metadata *[]byte) tlv.Record

NewMetadataRecord creates a tlv.Record that encodes the metadata (type 10) for an onion payload.

func NewTotalAmtMsatBlinded

func NewTotalAmtMsatBlinded(amt *uint64) tlv.Record

NewTotalAmtMsatBlinded creates a tlv.Record that encodes the total_amount_msat for the final an onion payload within a blinded route.

func ReadElement

func ReadElement(r io.Reader, element interface{}) error

ReadElement is a one-stop utility function to deserialize any datastructure encoded using the serialization format of the database.

func ReadElements

func ReadElements(r io.Reader, elements ...interface{}) error

ReadElements deserializes a variable number of elements into the passed io.Reader, with each element being deserialized according to the ReadElement function.

func SerializeRoute

func SerializeRoute(w io.Writer, r Route) error

SerializeRoute serializes a route.

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info.

func WriteElement

func WriteElement(w io.Writer, element interface{}) error

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

func WriteElements(w io.Writer, elements ...interface{}) error

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

func (a *AMP) PayloadSize() uint64

PayloadSize returns the size this record takes up in encoded form.

func (*AMP) Record

func (a *AMP) Record() tlv.Record

Record returns a tlv.Record that can be used to encode or decode this record.

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.

func (*MPP) Record

func (r *MPP) Record() tlv.Record

Record returns a tlv.Record that can be used to encode or decode this record.

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.

func DeserializeRoute

func DeserializeRoute(r io.Reader) (Route, error)

DeserializeRoute deserializes a route.

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.

type Vertex

type Vertex [VertexSize]byte

Vertex is a simple alias for the serialization of a compressed Bitcoin public key.

func (*Vertex) Record

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

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

Jump to

Keyboard shortcuts

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