lnwire

package
Version: v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2021 License: MIT Imports: 25 Imported by: 0

README

lnwire

Build Status MIT licensed GoDoc

The lnwire package implements the Lightning Network wire protocol.

This package has intentionally been designed so it can be used as a standalone package for any projects needing to interface with lightning peers at the wire protocol level.

Installation and Updating

⛰  go get -u github.com/John-Tonny/lnd/lnwire

Documentation

Index

Constants

View Source
const (
	// MaxSliceLength is the maximum allowed length for any opaque byte
	// slices in the wire protocol.
	MaxSliceLength = 65535

	// MaxMsgBody is the largest payload any message is allowed to provide.
	// This is two less than the MaxSliceLength as each message has a 2
	// byte type that precedes the message body.
	MaxMsgBody = 65533
)
View Source
const (
	MsgInit                    MessageType = 16
	MsgError                               = 17
	MsgPing                                = 18
	MsgPong                                = 19
	MsgOpenChannel                         = 32
	MsgAcceptChannel                       = 33
	MsgFundingCreated                      = 34
	MsgFundingSigned                       = 35
	MsgFundingLocked                       = 36
	MsgShutdown                            = 38
	MsgClosingSigned                       = 39
	MsgUpdateAddHTLC                       = 128
	MsgUpdateFulfillHTLC                   = 130
	MsgUpdateFailHTLC                      = 131
	MsgCommitSig                           = 132
	MsgRevokeAndAck                        = 133
	MsgUpdateFee                           = 134
	MsgUpdateFailMalformedHTLC             = 135
	MsgChannelReestablish                  = 136
	MsgChannelAnnouncement                 = 256
	MsgNodeAnnouncement                    = 257
	MsgChannelUpdate                       = 258
	MsgAnnounceSignatures                  = 259
	MsgQueryShortChanIDs                   = 261
	MsgReplyShortChanIDsEnd                = 262
	MsgQueryChannelRange                   = 263
	MsgReplyChannelRange                   = 264
	MsgGossipTimestampRange                = 265
)

The currently defined message types within this current version of the Lightning protocol.

View Source
const (
	CodeNone                             FailCode = 0
	CodeInvalidRealm                              = FlagBadOnion | 1
	CodeTemporaryNodeFailure                      = FlagNode | 2
	CodePermanentNodeFailure                      = FlagPerm | FlagNode | 2
	CodeRequiredNodeFeatureMissing                = FlagPerm | FlagNode | 3
	CodeInvalidOnionVersion                       = FlagBadOnion | FlagPerm | 4
	CodeInvalidOnionHmac                          = FlagBadOnion | FlagPerm | 5
	CodeInvalidOnionKey                           = FlagBadOnion | FlagPerm | 6
	CodeTemporaryChannelFailure                   = FlagUpdate | 7
	CodePermanentChannelFailure                   = FlagPerm | 8
	CodeRequiredChannelFeatureMissing             = FlagPerm | 9
	CodeUnknownNextPeer                           = FlagPerm | 10
	CodeAmountBelowMinimum                        = FlagUpdate | 11
	CodeFeeInsufficient                           = FlagUpdate | 12
	CodeIncorrectCltvExpiry                       = FlagUpdate | 13
	CodeExpiryTooSoon                             = FlagUpdate | 14
	CodeChannelDisabled                           = FlagUpdate | 20
	CodeIncorrectOrUnknownPaymentDetails          = FlagPerm | 15
	CodeIncorrectPaymentAmount                    = FlagPerm | 16
	CodeFinalExpiryTooSoon               FailCode = 17
	CodeFinalIncorrectCltvExpiry         FailCode = 18
	CodeFinalIncorrectHtlcAmount         FailCode = 19
	CodeExpiryTooFar                     FailCode = 21
	CodeInvalidOnionPayload                       = FlagPerm | 22
	CodeMPPTimeout                       FailCode = 23
)

The currently defined onion failure types within this current version of the Lightning protocol.

View Source
const (
	// DeliveryAddrType is the TLV record type for delivery addreses within
	// the name space of the OpenChannel and AcceptChannel messages.
	DeliveryAddrType = 0
)
View Source
const FailureMessageLength = 256

FailureMessageLength is the size of the failure message plus the size of padding. The FailureMessage message should always be EXACTLY this size.

View Source
const (
	// MaxFundingTxOutputs is the maximum number of allowed outputs on a
	// funding transaction within the protocol. This is due to the fact
	// that we use 2-bytes to encode the index within the funding output
	// during the funding workflow. Funding transaction with more outputs
	// than this are considered invalid within the protocol.
	MaxFundingTxOutputs = math.MaxUint16
)
View Source
const MaxMessagePayload = 65535 // 65KB

MaxMessagePayload is the maximum bytes a message can be regardless of other individual limits imposed by messages themselves.

View Source
const (

	// MaxMilliSatoshi is the maximum number of msats that can be expressed
	// in this data type.
	MaxMilliSatoshi = ^MilliSatoshi(0)
)
View Source
const OnionPacketSize = 1366

OnionPacketSize is the size of the serialized Sphinx onion packet included in each UpdateAddHTLC message. The breakdown of the onion packet is as follows: 1-byte version, 33-byte ephemeral public key (for ECDH), 1300-bytes of per-hop data, and a 32-byte HMAC over the entire packet.

Variables

View Source
var ConnectionWideID = ChannelID{}

ConnectionWideID is an all-zero ChannelID, which is used to represent a message intended for all channels to specific peer.

View Source
var (
	// ErrFeaturePairExists signals an error in feature vector construction
	// where the opposing bit in a feature pair has already been set.
	ErrFeaturePairExists = errors.New("feature pair exists")
)
View Source
var Features = map[FeatureBit]string{
	DataLossProtectRequired:       "data-loss-protect",
	DataLossProtectOptional:       "data-loss-protect",
	InitialRoutingSync:            "initial-routing-sync",
	UpfrontShutdownScriptRequired: "upfront-shutdown-script",
	UpfrontShutdownScriptOptional: "upfront-shutdown-script",
	GossipQueriesRequired:         "gossip-queries",
	GossipQueriesOptional:         "gossip-queries",
	TLVOnionPayloadRequired:       "tlv-onion",
	TLVOnionPayloadOptional:       "tlv-onion",
	StaticRemoteKeyOptional:       "static-remote-key",
	StaticRemoteKeyRequired:       "static-remote-key",
	PaymentAddrOptional:           "payment-addr",
	PaymentAddrRequired:           "payment-addr",
	MPPOptional:                   "multi-path-payments",
	MPPRequired:                   "multi-path-payments",
	AnchorsRequired:               "anchor-commitments",
	AnchorsOptional:               "anchor-commitments",
	AnchorsZeroFeeHtlcTxRequired:  "anchors-zero-fee-htlc-tx",
	AnchorsZeroFeeHtlcTxOptional:  "anchors-zero-fee-htlc-tx",
	WumboChannelsRequired:         "wumbo-channels",
	WumboChannelsOptional:         "wumbo-channels",
}

Features is a mapping of known feature bits to a descriptive name. All known feature bits must be assigned a name in this mapping, and feature bit pairs must be assigned together for correct behavior.

Functions

func EncodeFailure

func EncodeFailure(w io.Writer, failure FailureMessage, pver uint32) error

EncodeFailure encodes, including the necessary onion failure header information.

func EncodeFailureMessage

func EncodeFailureMessage(w io.Writer, failure FailureMessage, pver uint32) error

EncodeFailureMessage encodes just the failure message without adding a length and padding the message for the onion protocol.

func ErrUnknownShortChanIDEncoding

func ErrUnknownShortChanIDEncoding(encoding ShortChanIDEncoding) error

ErrUnknownShortChanIDEncoding is a parametrized error that indicates that we came across an unknown short channel ID encoding, and therefore were unable to continue parsing.

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 lnwire.

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 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 the wire protocol. The passed io.Writer should be backed by an appropriately sized byte slice, or be able to dynamically expand to accommodate additional data.

TODO(roasbeef): this should eventually draw from a buffer pool for serialization.

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.

func WriteMessage

func WriteMessage(w io.Writer, msg Message, pver uint32) (int, error)

WriteMessage writes a lightning Message to w including the necessary header information and returns the number of bytes written.

Types

type AcceptChannel

type AcceptChannel struct {
	// PendingChannelID serves to uniquely identify the future channel
	// created by the initiated single funder workflow.
	PendingChannelID [32]byte

	// DustLimit is the specific dust limit the sender of this message
	// would like enforced on their version of the commitment transaction.
	// Any output below this value will be "trimmed" from the commitment
	// transaction, with the amount of the HTLC going to dust.
	DustLimit vclutil.Amount

	// MaxValueInFlight represents the maximum amount of coins that can be
	// pending within the channel at any given time. If the amount of funds
	// in limbo exceeds this amount, then the channel will be failed.
	MaxValueInFlight MilliSatoshi

	// ChannelReserve is the amount of BTC that the receiving party MUST
	// maintain a balance above at all times. This is a safety mechanism to
	// ensure that both sides always have skin in the game during the
	// channel's lifetime.
	ChannelReserve vclutil.Amount

	// HtlcMinimum is the smallest HTLC that the sender of this message
	// will accept.
	HtlcMinimum MilliSatoshi

	// MinAcceptDepth is the minimum depth that the initiator of the
	// channel should wait before considering the channel open.
	MinAcceptDepth uint32

	// CsvDelay is the number of blocks to use for the relative time lock
	// in the pay-to-self output of both commitment transactions.
	CsvDelay uint16

	// MaxAcceptedHTLCs is the total number of incoming HTLC's that the
	// sender of this channel will accept.
	//
	// TODO(roasbeef): acks the initiator's, same with max in flight?
	MaxAcceptedHTLCs uint16

	// FundingKey is the key that should be used on behalf of the sender
	// within the 2-of-2 multi-sig output that it contained within the
	// funding transaction.
	FundingKey *btcec.PublicKey

	// RevocationPoint is the base revocation point for the sending party.
	// Any commitment transaction belonging to the receiver of this message
	// should use this key and their per-commitment point to derive the
	// revocation key for the commitment transaction.
	RevocationPoint *btcec.PublicKey

	// PaymentPoint is the base payment point for the sending party. This
	// key should be combined with the per commitment point for a
	// particular commitment state in order to create the key that should
	// be used in any output that pays directly to the sending party, and
	// also within the HTLC covenant transactions.
	PaymentPoint *btcec.PublicKey

	// DelayedPaymentPoint is the delay point for the sending party. This
	// key should be combined with the per commitment point to derive the
	// keys that are used in outputs of the sender's commitment transaction
	// where they claim funds.
	DelayedPaymentPoint *btcec.PublicKey

	// HtlcPoint is the base point used to derive the set of keys for this
	// party that will be used within the HTLC public key scripts.  This
	// value is combined with the receiver's revocation base point in order
	// to derive the keys that are used within HTLC scripts.
	HtlcPoint *btcec.PublicKey

	// FirstCommitmentPoint is the first commitment point for the sending
	// party. This value should be combined with the receiver's revocation
	// base point in order to derive the revocation keys that are placed
	// within the commitment transaction of the sender.
	FirstCommitmentPoint *btcec.PublicKey

	// UpfrontShutdownScript is the script to which the channel funds should
	// be paid when mutually closing the channel. This field is optional, and
	// and has a length prefix, so a zero will be written if it is not set
	// and its length followed by the script will be written if it is set.
	UpfrontShutdownScript DeliveryAddress

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	//
	// NOTE: Since the upfront shutdown script MUST be present (though can
	// be zero-length) if any TLV data is available, the script will be
	// extracted and removed from this blob when decoding. ExtraData will
	// contain all TLV records _except_ the DeliveryAddress record in that
	// case.
	ExtraData ExtraOpaqueData
}

AcceptChannel is the message Bob sends to Alice after she initiates the single funder channel workflow via an AcceptChannel message. Once Alice receives Bob's response, then she has all the items necessary to construct the funding transaction, and both commitment transactions.

func (*AcceptChannel) Decode

func (a *AcceptChannel) Decode(r io.Reader, pver uint32) error

Decode deserializes the serialized AcceptChannel stored in the passed io.Reader into the target AcceptChannel using the deserialization rules defined by the passed protocol version.

This is part of the lnwire.Message interface.

func (*AcceptChannel) Encode

func (a *AcceptChannel) Encode(w io.Writer, pver uint32) error

Encode serializes the target AcceptChannel into the passed io.Writer implementation. Serialization will observe the rules defined by the passed protocol version.

This is part of the lnwire.Message interface.

func (*AcceptChannel) MsgType

func (a *AcceptChannel) MsgType() MessageType

MsgType returns the MessageType code which uniquely identifies this message as an AcceptChannel on the wire.

This is part of the lnwire.Message interface.

type AnnounceSignatures

type AnnounceSignatures struct {
	// ChannelID is the unique description of the funding transaction.
	// Channel id is better for users and debugging and short channel id is
	// used for quick test on existence of the particular utxo inside the
	// block chain, because it contains information about block.
	ChannelID ChannelID

	// ShortChannelID is the unique description of the funding
	// transaction. It is constructed with the most significant 3 bytes
	// as the block height, the next 3 bytes indicating the transaction
	// index within the block, and the least significant two bytes
	// indicating the output index which pays to the channel.
	ShortChannelID ShortChannelID

	// NodeSignature is the signature which contains the signed announce
	// channel message, by this signature we proof that we possess of the
	// node pub key and creating the reference node_key -> bitcoin_key.
	NodeSignature Sig

	// BitcoinSignature is the signature which contains the signed node
	// public key, by this signature we proof that we possess of the
	// bitcoin key and and creating the reverse reference bitcoin_key ->
	// node_key.
	BitcoinSignature Sig

	// ExtraOpaqueData is the set of data that was appended to this
	// message, some of which we may not actually know how to iterate or
	// parse. By holding onto this data, we ensure that we're able to
	// properly validate the set of signatures that cover these new fields,
	// and ensure we're able to make upgrades to the network in a forwards
	// compatible manner.
	ExtraOpaqueData ExtraOpaqueData
}

AnnounceSignatures is a direct message between two endpoints of a channel and serves as an opt-in mechanism to allow the announcement of the channel to the rest of the network. It contains the necessary signatures by the sender to construct the channel announcement message.

func (*AnnounceSignatures) Decode

func (a *AnnounceSignatures) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized AnnounceSignatures stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*AnnounceSignatures) Encode

func (a *AnnounceSignatures) Encode(w io.Writer, pver uint32) error

Encode serializes the target AnnounceSignatures into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*AnnounceSignatures) MsgType

func (a *AnnounceSignatures) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

type ChanUpdateChanFlags

type ChanUpdateChanFlags uint8

ChanUpdateChanFlags is a bitfield that signals various options concerning a particular channel edge. Each bit is to be examined in order to determine how the ChannelUpdate message is to be interpreted.

const (
	// ChanUpdateDirection indicates the direction of a channel update. If
	// this bit is set to 0 if Node1 (the node with the "smaller" Node ID)
	// is updating the channel, and to 1 otherwise.
	ChanUpdateDirection ChanUpdateChanFlags = 1 << iota

	// ChanUpdateDisabled is a bit that indicates if the channel edge
	// selected by the ChanUpdateDirection bit is to be treated as being
	// disabled.
	ChanUpdateDisabled
)

func (ChanUpdateChanFlags) IsDisabled

func (c ChanUpdateChanFlags) IsDisabled() bool

IsDisabled determines whether the channel flags has the disabled bit set.

func (ChanUpdateChanFlags) String

func (c ChanUpdateChanFlags) String() string

String returns the bitfield flags as a string.

type ChanUpdateMsgFlags

type ChanUpdateMsgFlags uint8

ChanUpdateMsgFlags is a bitfield that signals whether optional fields are present in the ChannelUpdate.

const (
	// ChanUpdateOptionMaxHtlc is a bit that indicates whether the
	// optional htlc_maximum_msat field is present in this ChannelUpdate.
	ChanUpdateOptionMaxHtlc ChanUpdateMsgFlags = 1 << iota
)

func (ChanUpdateMsgFlags) HasMaxHtlc

func (c ChanUpdateMsgFlags) HasMaxHtlc() bool

HasMaxHtlc returns true if the htlc_maximum_msat option bit is set in the message flags.

func (ChanUpdateMsgFlags) String

func (c ChanUpdateMsgFlags) String() string

String returns the bitfield flags as a string.

type ChannelAnnouncement

type ChannelAnnouncement struct {
	// This signatures are used by nodes in order to create cross
	// references between node's channel and node. Requiring both nodes
	// to sign indicates they are both willing to route other payments via
	// this node.
	NodeSig1 Sig
	NodeSig2 Sig

	// This signatures are used by nodes in order to create cross
	// references between node's channel and node. Requiring the bitcoin
	// signatures proves they control the channel.
	BitcoinSig1 Sig
	BitcoinSig2 Sig

	// Features is the feature vector that encodes the features supported
	// by the target node. This field can be used to signal the type of the
	// channel, or modifications to the fields that would normally follow
	// this vector.
	Features *RawFeatureVector

	// ChainHash denotes the target chain that this channel was opened
	// within. This value should be the genesis hash of the target chain.
	ChainHash chainhash.Hash

	// ShortChannelID is the unique description of the funding transaction,
	// or where exactly it's located within the target blockchain.
	ShortChannelID ShortChannelID

	// The public keys of the two nodes who are operating the channel, such
	// that is NodeID1 the numerically-lesser than NodeID2 (ascending
	// numerical order).
	NodeID1 [33]byte
	NodeID2 [33]byte

	// Public keys which corresponds to the keys which was declared in
	// multisig funding transaction output.
	BitcoinKey1 [33]byte
	BitcoinKey2 [33]byte

	// ExtraOpaqueData is the set of data that was appended to this
	// message, some of which we may not actually know how to iterate or
	// parse. By holding onto this data, we ensure that we're able to
	// properly validate the set of signatures that cover these new fields,
	// and ensure we're able to make upgrades to the network in a forwards
	// compatible manner.
	ExtraOpaqueData ExtraOpaqueData
}

ChannelAnnouncement message is used to announce the existence of a channel between two peers in the overlay, which is propagated by the discovery service over broadcast handler.

func (*ChannelAnnouncement) DataToSign

func (a *ChannelAnnouncement) DataToSign() ([]byte, error)

DataToSign is used to retrieve part of the announcement message which should be signed.

func (*ChannelAnnouncement) Decode

func (a *ChannelAnnouncement) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized ChannelAnnouncement stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*ChannelAnnouncement) Encode

func (a *ChannelAnnouncement) Encode(w io.Writer, pver uint32) error

Encode serializes the target ChannelAnnouncement into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*ChannelAnnouncement) MsgType

func (a *ChannelAnnouncement) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

type ChannelID

type ChannelID [32]byte

ChannelID is a series of 32-bytes that uniquely identifies all channels within the network. The ChannelID is computed using the outpoint of the funding transaction (the txid, and output index). Given a funding output the ChannelID can be calculated by XOR'ing the big-endian serialization of the txid and the big-endian serialization of the output index, truncated to 2 bytes.

func NewChanIDFromOutPoint

func NewChanIDFromOutPoint(op *wire.OutPoint) ChannelID

NewChanIDFromOutPoint converts a target OutPoint into a ChannelID that is usable within the network. In order to convert the OutPoint into a ChannelID, we XOR the lower 2-bytes of the txid within the OutPoint with the big-endian serialization of the Index of the OutPoint, truncated to 2-bytes.

func (*ChannelID) GenPossibleOutPoints

func (c *ChannelID) GenPossibleOutPoints() [MaxFundingTxOutputs]wire.OutPoint

GenPossibleOutPoints generates all the possible outputs given a channel ID. In order to generate these possible outpoints, we perform a brute-force search through the candidate output index space, performing a reverse mapping from channelID back to OutPoint.

func (ChannelID) IsChanPoint

func (c ChannelID) IsChanPoint(op *wire.OutPoint) bool

IsChanPoint returns true if the OutPoint passed corresponds to the target ChannelID.

func (ChannelID) String

func (c ChannelID) String() string

String returns the string representation of the ChannelID. This is just the hex string encoding of the ChannelID itself.

type ChannelReestablish

type ChannelReestablish struct {
	// ChanID is the channel ID of the channel state we're attempting to
	// synchronize with the remote party.
	ChanID ChannelID

	// NextLocalCommitHeight is the next local commitment height of the
	// sending party. If the height of the sender's commitment chain from
	// the receiver's Pov is one less that this number, then the sender
	// should re-send the *exact* same proposed commitment.
	//
	// In other words, the receiver should re-send their last sent
	// commitment iff:
	//
	//  * NextLocalCommitHeight == remoteCommitChain.Height
	//
	// This covers the case of a lost commitment which was sent by the
	// sender of this message, but never received by the receiver of this
	// message.
	NextLocalCommitHeight uint64

	// RemoteCommitTailHeight is the height of the receiving party's
	// unrevoked commitment from the PoV of the sender of this message. If
	// the height of the receiver's commitment is *one more* than this
	// value, then their prior RevokeAndAck message should be
	// retransmitted.
	//
	// In other words, the receiver should re-send their last sent
	// RevokeAndAck message iff:
	//
	//  * localCommitChain.tail().Height == RemoteCommitTailHeight + 1
	//
	// This covers the case of a lost revocation, wherein the receiver of
	// the message sent a revocation for a prior state, but the sender of
	// the message never fully processed it.
	RemoteCommitTailHeight uint64

	// LastRemoteCommitSecret is the last commitment secret that the
	// receiving node has sent to the sending party. This will be the
	// secret of the last revoked commitment transaction. Including this
	// provides proof that the sending node at least knows of this state,
	// as they couldn't have produced it if it wasn't sent, as the value
	// can be authenticated by querying the shachain or the receiving
	// party.
	LastRemoteCommitSecret [32]byte

	// LocalUnrevokedCommitPoint is the commitment point used in the
	// current un-revoked commitment transaction of the sending party.
	LocalUnrevokedCommitPoint *btcec.PublicKey

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraData ExtraOpaqueData
}

ChannelReestablish is a message sent between peers that have an existing open channel upon connection reestablishment. This message allows both sides to report their local state, and their current knowledge of the state of the remote commitment chain. If a deviation is detected and can be recovered from, then the necessary messages will be retransmitted. If the level of desynchronization is irreconcilable, then the channel will be force closed.

func (*ChannelReestablish) Decode

func (a *ChannelReestablish) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized ChannelReestablish stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*ChannelReestablish) Encode

func (a *ChannelReestablish) Encode(w io.Writer, pver uint32) error

Encode serializes the target ChannelReestablish into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*ChannelReestablish) MsgType

func (a *ChannelReestablish) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

type ChannelUpdate

type ChannelUpdate struct {
	// Signature is used to validate the announced data and prove the
	// ownership of node id.
	Signature Sig

	// ChainHash denotes the target chain that this channel was opened
	// within. This value should be the genesis hash of the target chain.
	// Along with the short channel ID, this uniquely identifies the
	// channel globally in a blockchain.
	ChainHash chainhash.Hash

	// ShortChannelID is the unique description of the funding transaction.
	ShortChannelID ShortChannelID

	// Timestamp allows ordering in the case of multiple announcements. We
	// should ignore the message if timestamp is not greater than
	// the last-received.
	Timestamp uint32

	// MessageFlags is a bitfield that describes whether optional fields
	// are present in this update. Currently, the least-significant bit
	// must be set to 1 if the optional field MaxHtlc is present.
	MessageFlags ChanUpdateMsgFlags

	// ChannelFlags is a bitfield that describes additional meta-data
	// concerning how the update is to be interpreted. Currently, the
	// least-significant bit must be set to 0 if the creating node
	// corresponds to the first node in the previously sent channel
	// announcement and 1 otherwise. If the second bit is set, then the
	// channel is set to be disabled.
	ChannelFlags ChanUpdateChanFlags

	// TimeLockDelta is the minimum number of blocks this node requires to
	// be added to the expiry of HTLCs. This is a security parameter
	// determined by the node operator. This value represents the required
	// gap between the time locks of the incoming and outgoing HTLC's set
	// to this node.
	TimeLockDelta uint16

	// HtlcMinimumMsat is the minimum HTLC value which will be accepted.
	HtlcMinimumMsat MilliSatoshi

	// BaseFee is the base fee that must be used for incoming HTLC's to
	// this particular channel. This value will be tacked onto the required
	// for a payment independent of the size of the payment.
	BaseFee uint32

	// FeeRate is the fee rate that will be charged per millionth of a
	// satoshi.
	FeeRate uint32

	// HtlcMaximumMsat is the maximum HTLC value which will be accepted.
	HtlcMaximumMsat MilliSatoshi

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraOpaqueData ExtraOpaqueData
}

ChannelUpdate message is used after channel has been initially announced. Each side independently announces its fees and minimum expiry for HTLCs and other parameters. Also this message is used to redeclare initially set channel parameters.

func (*ChannelUpdate) DataToSign

func (a *ChannelUpdate) DataToSign() ([]byte, error)

DataToSign is used to retrieve part of the announcement message which should be signed.

func (*ChannelUpdate) Decode

func (a *ChannelUpdate) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized ChannelUpdate stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*ChannelUpdate) Encode

func (a *ChannelUpdate) Encode(w io.Writer, pver uint32) error

Encode serializes the target ChannelUpdate into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*ChannelUpdate) MsgType

func (a *ChannelUpdate) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

type ClosingSigned

type ClosingSigned struct {
	// ChannelID serves to identify which channel is to be closed.
	ChannelID ChannelID

	// FeeSatoshis is the total fee in satoshis that the party to the
	// channel would like to propose for the close transaction.
	FeeSatoshis vclutil.Amount

	// Signature is for the proposed channel close transaction.
	Signature Sig

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraData ExtraOpaqueData
}

ClosingSigned is sent by both parties to a channel once the channel is clear of HTLCs, and is primarily concerned with negotiating fees for the close transaction. Each party provides a signature for a transaction with a fee that they believe is fair. The process terminates when both sides agree on the same fee, or when one side force closes the channel.

NOTE: The responder is able to send a signature without any additional messages as all transactions are assembled observing BIP 69 which defines a canonical ordering for input/outputs. Therefore, both sides are able to arrive at an identical closure transaction as they know the order of the inputs/outputs.

func NewClosingSigned

func NewClosingSigned(cid ChannelID, fs vclutil.Amount,
	sig Sig) *ClosingSigned

NewClosingSigned creates a new empty ClosingSigned message.

func (*ClosingSigned) Decode

func (c *ClosingSigned) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized ClosingSigned message stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*ClosingSigned) Encode

func (c *ClosingSigned) Encode(w io.Writer, pver uint32) error

Encode serializes the target ClosingSigned into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*ClosingSigned) MsgType

func (c *ClosingSigned) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

type CommitSig

type CommitSig struct {
	// ChanID uniquely identifies to which currently active channel this
	// CommitSig applies to.
	ChanID ChannelID

	// CommitSig is Alice's signature for Bob's new commitment transaction.
	// Alice is able to send this signature without requesting any
	// additional data due to the piggybacking of Bob's next revocation
	// hash in his prior RevokeAndAck message, as well as the canonical
	// ordering used for all inputs/outputs within commitment transactions.
	// If initiating a new commitment state, this signature should ONLY
	// cover all of the sending party's pending log updates, and the log
	// updates of the remote party that have been ACK'd.
	CommitSig Sig

	// HtlcSigs is a signature for each relevant HTLC output within the
	// created commitment. The order of the signatures is expected to be
	// identical to the placement of the HTLC's within the BIP 69 sorted
	// commitment transaction. For each outgoing HTLC (from the PoV of the
	// sender of this message), a signature for an HTLC timeout transaction
	// should be signed, for each incoming HTLC the HTLC timeout
	// transaction should be signed.
	HtlcSigs []Sig

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraData ExtraOpaqueData
}

CommitSig is sent by either side to stage any pending HTLC's in the receiver's pending set into a new commitment state. Implicitly, the new commitment transaction constructed which has been signed by CommitSig includes all HTLC's in the remote node's pending set. A CommitSig message may be sent after a series of UpdateAddHTLC/UpdateFulfillHTLC messages in order to batch add several HTLC's with a single signature covering all implicitly accepted HTLC's.

func NewCommitSig

func NewCommitSig() *CommitSig

NewCommitSig creates a new empty CommitSig message.

func (*CommitSig) Decode

func (c *CommitSig) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized CommitSig message stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*CommitSig) Encode

func (c *CommitSig) Encode(w io.Writer, pver uint32) error

Encode serializes the target CommitSig into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*CommitSig) MsgType

func (c *CommitSig) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

func (*CommitSig) TargetChanID

func (c *CommitSig) TargetChanID() ChannelID

TargetChanID returns the channel id of the link for which this message is intended.

NOTE: Part of peer.LinkUpdater interface.

type DeliveryAddress

type DeliveryAddress []byte

DeliveryAddress is used to communicate the address to which funds from a closed channel should be sent. The address can be a p2wsh, p2pkh, p2sh or p2wpkh.

func (*DeliveryAddress) NewRecord

func (d *DeliveryAddress) NewRecord() tlv.Record

NewRecord returns a TLV record that can be used to encode the delivery address within the ExtraData TLV stream. This was intorudced in order to allow the OpenChannel/AcceptChannel messages to properly be extended with TLV types.

type ErrInvalidNodeAlias

type ErrInvalidNodeAlias struct{}

ErrInvalidNodeAlias is an error returned if a node alias we parse on the wire is invalid, as in it has non UTF-8 characters.

func (ErrInvalidNodeAlias) Error

func (e ErrInvalidNodeAlias) Error() string

Error returns a human readable string describing the error.

NOTE: implements the error interface.

type ErrUnknownAddrType

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

ErrUnknownAddrType is an error returned if we encounter an unknown address type when parsing addresses.

func (ErrUnknownAddrType) Error

func (e ErrUnknownAddrType) Error() string

Error returns a human readable string describing the error.

NOTE: implements the error interface.

type ErrUnsortedSIDs

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

ErrUnsortedSIDs is returned when decoding a QueryShortChannelID request whose items were not sorted.

func (ErrUnsortedSIDs) Error

func (e ErrUnsortedSIDs) Error() string

Error returns a human-readable description of the error.

type Error

type Error struct {
	// ChanID references the active channel in which the error occurred
	// within. If the ChanID is all zeros, then this error applies to the
	// entire established connection.
	ChanID ChannelID

	// Data is the attached error data that describes the exact failure
	// which caused the error message to be sent.
	Data ErrorData
}

Error represents a generic error bound to an exact channel. The message format is purposefully general in order to allow expression of a wide array of possible errors. Each Error message is directed at a particular open channel referenced by ChannelPoint.

func NewError

func NewError() *Error

NewError creates a new Error message.

func (*Error) Decode

func (c *Error) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized Error message stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*Error) Encode

func (c *Error) Encode(w io.Writer, pver uint32) error

Encode serializes the target Error into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*Error) Error

func (c *Error) Error() string

Error returns the string representation to Error.

NOTE: Satisfies the error interface.

func (*Error) MsgType

func (c *Error) MsgType() MessageType

MsgType returns the integer uniquely identifying an Error message on the wire.

This is part of the lnwire.Message interface.

type ErrorData

type ErrorData []byte

ErrorData is a set of bytes associated with a particular sent error. A receiving node SHOULD only print out data verbatim if the string is composed solely of printable ASCII characters. For reference, the printable character set includes byte values 32 through 127 inclusive.

type ExtraOpaqueData

type ExtraOpaqueData []byte

ExtraOpaqueData is the set of data that was appended to this message, some of which we may not actually know how to iterate or parse. By holding onto this data, we ensure that we're able to properly validate the set of signatures that cover these new fields, and ensure we're able to make upgrades to the network in a forwards compatible manner.

func (*ExtraOpaqueData) Decode

func (e *ExtraOpaqueData) Decode(r io.Reader) error

Decode attempts to unpack the raw bytes encoded in the passed io.Reader as a set of extra opaque data.

func (*ExtraOpaqueData) Encode

func (e *ExtraOpaqueData) Encode(w io.Writer) error

Encode attempts to encode the raw extra bytes into the passed io.Writer.

func (*ExtraOpaqueData) ExtractRecords

func (e *ExtraOpaqueData) ExtractRecords(records ...tlv.Record) (
	tlv.TypeMap, error)

ExtractRecords attempts to decode any types in the internal raw bytes as if it were a tlv stream. The set of raw parsed types is returned, and any passed records (if found in the stream) will be parsed into the proper tlv.Record.

func (*ExtraOpaqueData) PackRecords

func (e *ExtraOpaqueData) PackRecords(records ...tlv.Record) error

PackRecords attempts to encode the set of tlv records into the target ExtraOpaqueData instance. The records will be encoded as a raw TLV stream and stored within the backing slice pointer.

type FailAmountBelowMinimum

type FailAmountBelowMinimum struct {
	// HtlcMsat is the wrong amount of the incoming HTLC.
	HtlcMsat MilliSatoshi

	// Update is used to update information about state of the channel
	// which caused the failure.
	Update ChannelUpdate
}

FailAmountBelowMinimum is returned if the HTLC does not reach the current minimum amount, we tell them the amount of the incoming HTLC and the current channel setting for the outgoing channel.

NOTE: May only be returned by the intermediate nodes in the path.

func NewAmountBelowMinimum

func NewAmountBelowMinimum(htlcMsat MilliSatoshi,
	update ChannelUpdate) *FailAmountBelowMinimum

NewAmountBelowMinimum creates new instance of the FailAmountBelowMinimum.

func (*FailAmountBelowMinimum) Code

func (f *FailAmountBelowMinimum) Code() FailCode

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailAmountBelowMinimum) Decode

func (f *FailAmountBelowMinimum) Decode(r io.Reader, pver uint32) error

Decode decodes the failure from bytes stream.

NOTE: Part of the Serializable interface.

func (*FailAmountBelowMinimum) Encode

func (f *FailAmountBelowMinimum) Encode(w io.Writer, pver uint32) error

Encode writes the failure in bytes stream.

NOTE: Part of the Serializable interface.

func (*FailAmountBelowMinimum) Error

func (f *FailAmountBelowMinimum) Error() string

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailChannelDisabled

type FailChannelDisabled struct {
	// Flags least-significant bit must be set to 0 if the creating node
	// corresponds to the first node in the previously sent channel
	// announcement and 1 otherwise.
	Flags uint16

	// Update is used to update information about state of the channel
	// which caused the failure.
	Update ChannelUpdate
}

FailChannelDisabled is returned if the channel is disabled, we tell them the current channel setting for the outgoing channel.

NOTE: May only be returned by intermediate nodes.

func NewChannelDisabled

func NewChannelDisabled(flags uint16, update ChannelUpdate) *FailChannelDisabled

NewChannelDisabled creates new instance of the FailChannelDisabled.

func (*FailChannelDisabled) Code

func (f *FailChannelDisabled) Code() FailCode

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailChannelDisabled) Decode

func (f *FailChannelDisabled) Decode(r io.Reader, pver uint32) error

Decode decodes the failure from bytes stream.

NOTE: Part of the Serializable interface.

func (*FailChannelDisabled) Encode

func (f *FailChannelDisabled) Encode(w io.Writer, pver uint32) error

Encode writes the failure in bytes stream.

NOTE: Part of the Serializable interface.

func (*FailChannelDisabled) Error

func (f *FailChannelDisabled) Error() string

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailCode

type FailCode uint16

FailCode specifies the precise reason that an upstream HTLC was canceled. Each UpdateFailHTLC message carries a FailCode which is to be passed backwards, encrypted at each step back to the source of the HTLC within the route.

const (
	// FlagBadOnion error flag describes an unparsable, encrypted by
	// previous node.
	FlagBadOnion FailCode = 0x8000

	// FlagPerm error flag indicates a permanent failure.
	FlagPerm FailCode = 0x4000

	// FlagNode error flag indicates a node failure.
	FlagNode FailCode = 0x2000

	// FlagUpdate error flag indicates a new channel update is enclosed
	// within the error.
	FlagUpdate FailCode = 0x1000
)

func (FailCode) String

func (c FailCode) String() string

String returns the string representation of the failure code.

type FailExpiryTooFar

type FailExpiryTooFar struct{}

FailExpiryTooFar is returned if the CLTV expiry in the HTLC is too far in the future.

NOTE: May be returned by any node in the payment route.

func (*FailExpiryTooFar) Code

func (f *FailExpiryTooFar) Code() FailCode

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailExpiryTooFar) Error

func (f *FailExpiryTooFar) Error() string

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailExpiryTooSoon

type FailExpiryTooSoon struct {
	// Update is used to update information about state of the channel
	// which caused the failure.
	Update ChannelUpdate
}

FailExpiryTooSoon is returned if the ctlv-expiry is too near, we tell them the current channel setting for the outgoing channel.

NOTE: May only be returned by intermediate nodes.

func NewExpiryTooSoon

func NewExpiryTooSoon(update ChannelUpdate) *FailExpiryTooSoon

NewExpiryTooSoon creates new instance of the FailExpiryTooSoon.

func (*FailExpiryTooSoon) Code

func (f *FailExpiryTooSoon) Code() FailCode

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailExpiryTooSoon) Decode

func (f *FailExpiryTooSoon) Decode(r io.Reader, pver uint32) error

Decode decodes the failure from l stream.

NOTE: Part of the Serializable interface.

func (*FailExpiryTooSoon) Encode

func (f *FailExpiryTooSoon) Encode(w io.Writer, pver uint32) error

Encode writes the failure in bytes stream.

NOTE: Part of the Serializable interface.

func (*FailExpiryTooSoon) Error

func (f *FailExpiryTooSoon) Error() string

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailFeeInsufficient

type FailFeeInsufficient struct {
	// HtlcMsat is the wrong amount of the incoming HTLC.
	HtlcMsat MilliSatoshi

	// Update is used to update information about state of the channel
	// which caused the failure.
	Update ChannelUpdate
}

FailFeeInsufficient is returned if the HTLC does not pay sufficient fee, we tell them the amount of the incoming HTLC and the current channel setting for the outgoing channel.

NOTE: May only be returned by intermediate nodes.

func NewFeeInsufficient

func NewFeeInsufficient(htlcMsat MilliSatoshi,
	update ChannelUpdate) *FailFeeInsufficient

NewFeeInsufficient creates new instance of the FailFeeInsufficient.

func (*FailFeeInsufficient) Code

func (f *FailFeeInsufficient) Code() FailCode

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailFeeInsufficient) Decode

func (f *FailFeeInsufficient) Decode(r io.Reader, pver uint32) error

Decode decodes the failure from bytes stream.

NOTE: Part of the Serializable interface.

func (*FailFeeInsufficient) Encode

func (f *FailFeeInsufficient) Encode(w io.Writer, pver uint32) error

Encode writes the failure in bytes stream.

NOTE: Part of the Serializable interface.

func (*FailFeeInsufficient) Error

func (f *FailFeeInsufficient) Error() string

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailFinalExpiryTooSoon

type FailFinalExpiryTooSoon struct{}

FailFinalExpiryTooSoon is returned if the cltv_expiry is too low, the final node MUST fail the HTLC.

NOTE: May only be returned by the final node in the path.

func NewFinalExpiryTooSoon

func NewFinalExpiryTooSoon() *FailFinalExpiryTooSoon

NewFinalExpiryTooSoon creates new instance of the FailFinalExpiryTooSoon.

func (*FailFinalExpiryTooSoon) Code

func (f *FailFinalExpiryTooSoon) Code() FailCode

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailFinalExpiryTooSoon) Error

func (f *FailFinalExpiryTooSoon) Error() string

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailFinalIncorrectCltvExpiry

type FailFinalIncorrectCltvExpiry struct {
	// CltvExpiry is the wrong absolute timeout in blocks, after which
	// outgoing HTLC expires.
	CltvExpiry uint32
}

FailFinalIncorrectCltvExpiry is returned if the outgoing_cltv_value does not match the ctlv_expiry of the HTLC at the final hop.

NOTE: might be returned by final node only.

func NewFinalIncorrectCltvExpiry

func NewFinalIncorrectCltvExpiry(cltvExpiry uint32) *FailFinalIncorrectCltvExpiry

NewFinalIncorrectCltvExpiry creates new instance of the FailFinalIncorrectCltvExpiry.

func (*FailFinalIncorrectCltvExpiry) Code

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailFinalIncorrectCltvExpiry) Decode

func (f *FailFinalIncorrectCltvExpiry) Decode(r io.Reader, pver uint32) error

Decode decodes the failure from bytes stream.

NOTE: Part of the Serializable interface.

func (*FailFinalIncorrectCltvExpiry) Encode

func (f *FailFinalIncorrectCltvExpiry) Encode(w io.Writer, pver uint32) error

Encode writes the failure in bytes stream.

NOTE: Part of the Serializable interface.

func (*FailFinalIncorrectCltvExpiry) Error

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailFinalIncorrectHtlcAmount

type FailFinalIncorrectHtlcAmount struct {
	// IncomingHTLCAmount is the wrong forwarded htlc amount.
	IncomingHTLCAmount MilliSatoshi
}

FailFinalIncorrectHtlcAmount is returned if the amt_to_forward is higher than incoming_htlc_amt of the HTLC at the final hop.

NOTE: May only be returned by the final node.

func NewFinalIncorrectHtlcAmount

func NewFinalIncorrectHtlcAmount(amount MilliSatoshi) *FailFinalIncorrectHtlcAmount

NewFinalIncorrectHtlcAmount creates new instance of the FailFinalIncorrectHtlcAmount.

func (*FailFinalIncorrectHtlcAmount) Code

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailFinalIncorrectHtlcAmount) Decode

func (f *FailFinalIncorrectHtlcAmount) Decode(r io.Reader, pver uint32) error

Decode decodes the failure from bytes stream.

NOTE: Part of the Serializable interface.

func (*FailFinalIncorrectHtlcAmount) Encode

func (f *FailFinalIncorrectHtlcAmount) Encode(w io.Writer, pver uint32) error

Encode writes the failure in bytes stream.

NOTE: Part of the Serializable interface.

func (*FailFinalIncorrectHtlcAmount) Error

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailIncorrectCltvExpiry

type FailIncorrectCltvExpiry struct {
	// CltvExpiry is the wrong absolute timeout in blocks, after which
	// outgoing HTLC expires.
	CltvExpiry uint32

	// Update is used to update information about state of the channel
	// which caused the failure.
	Update ChannelUpdate
}

FailIncorrectCltvExpiry is returned if outgoing cltv value does not match the update add htlc's cltv expiry minus cltv expiry delta for the outgoing channel, we tell them the cltv expiry and the current channel setting for the outgoing channel.

NOTE: May only be returned by intermediate nodes.

func NewIncorrectCltvExpiry

func NewIncorrectCltvExpiry(cltvExpiry uint32,
	update ChannelUpdate) *FailIncorrectCltvExpiry

NewIncorrectCltvExpiry creates new instance of the FailIncorrectCltvExpiry.

func (*FailIncorrectCltvExpiry) Code

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailIncorrectCltvExpiry) Decode

func (f *FailIncorrectCltvExpiry) Decode(r io.Reader, pver uint32) error

Decode decodes the failure from bytes stream.

NOTE: Part of the Serializable interface.

func (*FailIncorrectCltvExpiry) Encode

func (f *FailIncorrectCltvExpiry) Encode(w io.Writer, pver uint32) error

Encode writes the failure in bytes stream.

NOTE: Part of the Serializable interface.

func (*FailIncorrectCltvExpiry) Error

func (f *FailIncorrectCltvExpiry) Error() string

type FailIncorrectDetails

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

FailIncorrectDetails is returned for two reasons:

1) if the payment hash has already been paid, the final node MAY treat the payment hash as unknown, or may succeed in accepting the HTLC. If the payment hash is unknown, the final node MUST fail the HTLC.

2) if the amount paid is less than the amount expected, the final node MUST fail the HTLC. If the amount paid is more than twice the amount expected, the final node SHOULD fail the HTLC. This allows the sender to reduce information leakage by altering the amount, without allowing accidental gross overpayment.

NOTE: May only be returned by the final node in the path.

func NewFailIncorrectDetails

func NewFailIncorrectDetails(amt MilliSatoshi,
	height uint32) *FailIncorrectDetails

NewFailIncorrectDetails makes a new instance of the FailIncorrectDetails error bound to the specified HTLC amount and acceptance height.

func (*FailIncorrectDetails) Amount

func (f *FailIncorrectDetails) Amount() MilliSatoshi

Amount is the value of the extended HTLC.

func (*FailIncorrectDetails) Code

func (f *FailIncorrectDetails) Code() FailCode

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailIncorrectDetails) Decode

func (f *FailIncorrectDetails) Decode(r io.Reader, pver uint32) error

Decode decodes the failure from bytes stream.

NOTE: Part of the Serializable interface.

func (*FailIncorrectDetails) Encode

func (f *FailIncorrectDetails) Encode(w io.Writer, pver uint32) error

Encode writes the failure in bytes stream.

NOTE: Part of the Serializable interface.

func (*FailIncorrectDetails) Error

func (f *FailIncorrectDetails) Error() string

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

func (*FailIncorrectDetails) Height

func (f *FailIncorrectDetails) Height() uint32

Height is the block height when the htlc was received.

type FailIncorrectPaymentAmount

type FailIncorrectPaymentAmount struct{}

FailIncorrectPaymentAmount is returned if the amount paid is less than the amount expected, the final node MUST fail the HTLC. If the amount paid is more than twice the amount expected, the final node SHOULD fail the HTLC. This allows the sender to reduce information leakage by altering the amount, without allowing accidental gross overpayment.

NOTE: May only be returned by the final node in the path.

func (*FailIncorrectPaymentAmount) Code

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailIncorrectPaymentAmount) Error

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailInvalidOnionHmac

type FailInvalidOnionHmac struct {
	// OnionSHA256 hash of the onion blob which haven't been proceeded.
	OnionSHA256 [sha256.Size]byte
}

FailInvalidOnionHmac is return if the onion HMAC is incorrect.

NOTE: May only be returned by intermediate nodes.

func NewInvalidOnionHmac

func NewInvalidOnionHmac(onion []byte) *FailInvalidOnionHmac

NewInvalidOnionHmac creates new instance of the FailInvalidOnionHmac.

func (*FailInvalidOnionHmac) Code

func (f *FailInvalidOnionHmac) Code() FailCode

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailInvalidOnionHmac) Decode

func (f *FailInvalidOnionHmac) Decode(r io.Reader, pver uint32) error

Decode decodes the failure from bytes stream.

NOTE: Part of the Serializable interface.

func (*FailInvalidOnionHmac) Encode

func (f *FailInvalidOnionHmac) Encode(w io.Writer, pver uint32) error

Encode writes the failure in bytes stream.

NOTE: Part of the Serializable interface.

func (*FailInvalidOnionHmac) Error

func (f *FailInvalidOnionHmac) Error() string

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailInvalidOnionKey

type FailInvalidOnionKey struct {
	// OnionSHA256 hash of the onion blob which haven't been proceeded.
	OnionSHA256 [sha256.Size]byte
}

FailInvalidOnionKey is return if the ephemeral key in the onion is unparsable.

NOTE: May only be returned by intermediate nodes.

func NewInvalidOnionKey

func NewInvalidOnionKey(onion []byte) *FailInvalidOnionKey

NewInvalidOnionKey creates new instance of the FailInvalidOnionKey.

func (*FailInvalidOnionKey) Code

func (f *FailInvalidOnionKey) Code() FailCode

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailInvalidOnionKey) Decode

func (f *FailInvalidOnionKey) Decode(r io.Reader, pver uint32) error

Decode decodes the failure from bytes stream.

NOTE: Part of the Serializable interface.

func (*FailInvalidOnionKey) Encode

func (f *FailInvalidOnionKey) Encode(w io.Writer, pver uint32) error

Encode writes the failure in bytes stream.

NOTE: Part of the Serializable interface.

func (*FailInvalidOnionKey) Error

func (f *FailInvalidOnionKey) Error() string

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailInvalidOnionVersion

type FailInvalidOnionVersion struct {
	// OnionSHA256 hash of the onion blob which haven't been proceeded.
	OnionSHA256 [sha256.Size]byte
}

FailInvalidOnionVersion is returned if the onion version byte is unknown.

NOTE: May be returned only by intermediate nodes.

func NewInvalidOnionVersion

func NewInvalidOnionVersion(onion []byte) *FailInvalidOnionVersion

NewInvalidOnionVersion creates new instance of the FailInvalidOnionVersion.

func (*FailInvalidOnionVersion) Code

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailInvalidOnionVersion) Decode

func (f *FailInvalidOnionVersion) Decode(r io.Reader, pver uint32) error

Decode decodes the failure from bytes stream.

NOTE: Part of the Serializable interface.

func (*FailInvalidOnionVersion) Encode

func (f *FailInvalidOnionVersion) Encode(w io.Writer, pver uint32) error

Encode writes the failure in bytes stream.

NOTE: Part of the Serializable interface.

func (*FailInvalidOnionVersion) Error

func (f *FailInvalidOnionVersion) Error() string

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailInvalidRealm

type FailInvalidRealm struct{}

FailInvalidRealm is returned if the realm byte is unknown.

NOTE: May be returned by any node in the payment route.

func (*FailInvalidRealm) Code

func (f *FailInvalidRealm) Code() FailCode

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailInvalidRealm) Error

func (f *FailInvalidRealm) Error() string

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailMPPTimeout

type FailMPPTimeout struct{}

FailMPPTimeout is returned if the complete amount for a multi part payment was not received within a reasonable time.

NOTE: May only be returned by the final node in the path.

func (*FailMPPTimeout) Code

func (f *FailMPPTimeout) Code() FailCode

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailMPPTimeout) Error

func (f *FailMPPTimeout) Error() string

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailPermanentChannelFailure

type FailPermanentChannelFailure struct{}

FailPermanentChannelFailure is return if an otherwise unspecified permanent error occurs for the outgoing channel (eg. channel (recently).

NOTE: May be returned by any node in the payment route.

func (*FailPermanentChannelFailure) Code

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailPermanentChannelFailure) Error

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailPermanentNodeFailure

type FailPermanentNodeFailure struct{}

FailPermanentNodeFailure is returned if an otherwise unspecified permanent error occurs for the entire node.

NOTE: May be returned by any node in the payment route.

func (*FailPermanentNodeFailure) Code

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailPermanentNodeFailure) Error

func (f *FailPermanentNodeFailure) Error() string

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailRequiredChannelFeatureMissing

type FailRequiredChannelFeatureMissing struct{}

FailRequiredChannelFeatureMissing is returned if the outgoing channel has a requirement advertised in its channel announcement features which were not present in the onion.

NOTE: May only be returned by intermediate nodes.

func (*FailRequiredChannelFeatureMissing) Code

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailRequiredChannelFeatureMissing) Error

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailRequiredNodeFeatureMissing

type FailRequiredNodeFeatureMissing struct{}

FailRequiredNodeFeatureMissing is returned if a node has requirement advertised in its node_announcement features which were not present in the onion.

NOTE: May be returned by any node in the payment route.

func (*FailRequiredNodeFeatureMissing) Code

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailRequiredNodeFeatureMissing) Error

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailTemporaryChannelFailure

type FailTemporaryChannelFailure struct {
	// Update is used to update information about state of the channel
	// which caused the failure.
	//
	// NOTE: This field is optional.
	Update *ChannelUpdate
}

FailTemporaryChannelFailure is if an otherwise unspecified transient error occurs for the outgoing channel (eg. channel capacity reached, too many in-flight htlcs)

NOTE: May only be returned by intermediate nodes.

func NewTemporaryChannelFailure

func NewTemporaryChannelFailure(update *ChannelUpdate) *FailTemporaryChannelFailure

NewTemporaryChannelFailure creates new instance of the FailTemporaryChannelFailure.

func (*FailTemporaryChannelFailure) Code

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailTemporaryChannelFailure) Decode

func (f *FailTemporaryChannelFailure) Decode(r io.Reader, pver uint32) error

Decode decodes the failure from bytes stream.

NOTE: Part of the Serializable interface.

func (*FailTemporaryChannelFailure) Encode

func (f *FailTemporaryChannelFailure) Encode(w io.Writer, pver uint32) error

Encode writes the failure in bytes stream.

NOTE: Part of the Serializable interface.

func (*FailTemporaryChannelFailure) Error

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailTemporaryNodeFailure

type FailTemporaryNodeFailure struct{}

FailTemporaryNodeFailure is returned if an otherwise unspecified transient error occurs for the entire node.

NOTE: May be returned by any node in the payment route.

func (*FailTemporaryNodeFailure) Code

Code returns the failure unique code. NOTE: Part of the FailureMessage interface.

func (*FailTemporaryNodeFailure) Error

func (f *FailTemporaryNodeFailure) Error() string

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailUnknownNextPeer

type FailUnknownNextPeer struct{}

FailUnknownNextPeer is returned if the next peer specified by the onion is not known.

NOTE: May only be returned by intermediate nodes.

func (*FailUnknownNextPeer) Code

func (f *FailUnknownNextPeer) Code() FailCode

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailUnknownNextPeer) Error

func (f *FailUnknownNextPeer) Error() string

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type FailureMessage

type FailureMessage interface {
	// Code returns a failure code describing the exact nature of the
	// error.
	Code() FailCode

	// Error returns a human readable string describing the error. With
	// this method, the FailureMessage interface meets the built-in error
	// interface.
	Error() string
}

FailureMessage represents the onion failure object identified by its unique failure code.

func DecodeFailure

func DecodeFailure(r io.Reader, pver uint32) (FailureMessage, error)

DecodeFailure decodes, validates, and parses the lnwire onion failure, for the provided protocol version.

func DecodeFailureMessage

func DecodeFailureMessage(r io.Reader, pver uint32) (FailureMessage, error)

DecodeFailureMessage decodes just the failure message, ignoring any padding that may be present at the end.

type FeatureBit

type FeatureBit uint16

FeatureBit represents a feature that can be enabled in either a local or global feature vector at a specific bit position. Feature bits follow the "it's OK to be odd" rule, where features at even bit positions must be known to a node receiving them from a peer while odd bits do not. In accordance, feature bits are usually assigned in pairs, first being assigned an odd bit position which may later be changed to the preceding even position once knowledge of the feature becomes required on the network.

const (
	// DataLossProtectRequired is a feature bit that indicates that a peer
	// *requires* the other party know about the data-loss-protect optional
	// feature. If the remote peer does not know of such a feature, then
	// the sending peer SHOLUD disconnect them. The data-loss-protect
	// feature allows a peer that's lost partial data to recover their
	// settled funds of the latest commitment state.
	DataLossProtectRequired FeatureBit = 0

	// DataLossProtectOptional is an optional feature bit that indicates
	// that the sending peer knows of this new feature and can activate it
	// it. The data-loss-protect feature allows a peer that's lost partial
	// data to recover their settled funds of the latest commitment state.
	DataLossProtectOptional FeatureBit = 1

	// InitialRoutingSync is a local feature bit meaning that the receiving
	// node should send a complete dump of routing information when a new
	// connection is established.
	InitialRoutingSync FeatureBit = 3

	// UpfrontShutdownScriptRequired is a feature bit which indicates that a
	// peer *requires* that the remote peer accept an upfront shutdown script to
	// which payout is enforced on cooperative closes.
	UpfrontShutdownScriptRequired FeatureBit = 4

	// UpfrontShutdownScriptOptional is an optional feature bit which indicates
	// that the peer will accept an upfront shutdown script to which payout is
	// enforced on cooperative closes.
	UpfrontShutdownScriptOptional FeatureBit = 5

	// GossipQueriesRequired is a feature bit that indicates that the
	// receiving peer MUST know of the set of features that allows nodes to
	// more efficiently query the network view of peers on the network for
	// reconciliation purposes.
	GossipQueriesRequired FeatureBit = 6

	// GossipQueriesOptional is an optional feature bit that signals that
	// the setting peer knows of the set of features that allows more
	// efficient network view reconciliation.
	GossipQueriesOptional FeatureBit = 7

	// TLVOnionPayloadRequired is a feature bit that indicates a node is
	// able to decode the new TLV information included in the onion packet.
	TLVOnionPayloadRequired FeatureBit = 8

	// TLVOnionPayloadOptional is an optional feature bit that indicates a
	// node is able to decode the new TLV information included in the onion
	// packet.
	TLVOnionPayloadOptional FeatureBit = 9

	// StaticRemoteKeyRequired is a required feature bit that signals that
	// within one's commitment transaction, the key used for the remote
	// party's non-delay output should not be tweaked.
	StaticRemoteKeyRequired FeatureBit = 12

	// StaticRemoteKeyOptional is an optional feature bit that signals that
	// within one's commitment transaction, the key used for the remote
	// party's non-delay output should not be tweaked.
	StaticRemoteKeyOptional FeatureBit = 13

	// PaymentAddrRequired is a required feature bit that signals that a
	// node requires payment addresses, which are used to mitigate probing
	// attacks on the receiver of a payment.
	PaymentAddrRequired FeatureBit = 14

	// PaymentAddrOptional is an optional feature bit that signals that a
	// node supports payment addresses, which are used to mitigate probing
	// attacks on the receiver of a payment.
	PaymentAddrOptional FeatureBit = 15

	// MPPOptional is a required feature bit that signals that the receiver
	// of a payment requires settlement of an invoice with more than one
	// HTLC.
	MPPRequired FeatureBit = 16

	// MPPOptional is an optional feature bit that signals that the receiver
	// of a payment supports settlement of an invoice with more than one
	// HTLC.
	MPPOptional FeatureBit = 17

	// WumboChannelsRequired is a required feature bit that signals that a
	// node is willing to accept channels larger than 2^24 satoshis.
	WumboChannelsRequired FeatureBit = 18

	// WumboChannelsOptional is an optional feature bit that signals that a
	// node is willing to accept channels larger than 2^24 satoshis.
	WumboChannelsOptional FeatureBit = 19

	// AnchorsRequired is a required feature bit that signals that the node
	// requires channels to be made using commitments having anchor
	// outputs.
	AnchorsRequired FeatureBit = 20

	// AnchorsOptional is an optional feature bit that signals that the
	// node supports channels to be made using commitments having anchor
	// outputs.
	AnchorsOptional FeatureBit = 21

	// AnchorsZeroFeeHtlcTxRequired is a required feature bit that signals
	// that the node requires channels having zero-fee second-level HTLC
	// transactions, which also imply anchor commitments.
	AnchorsZeroFeeHtlcTxRequired FeatureBit = 22

	// AnchorsZeroFeeHtlcTxRequired is an optional feature bit that signals
	// that the node supports channels having zero-fee second-level HTLC
	// transactions, which also imply anchor commitments.
	AnchorsZeroFeeHtlcTxOptional FeatureBit = 23
)

func (FeatureBit) IsRequired

func (b FeatureBit) IsRequired() bool

IsRequired returns true if the feature bit is even, and false otherwise.

type FeatureVector

type FeatureVector struct {
	*RawFeatureVector
	// contains filtered or unexported fields
}

FeatureVector represents a set of enabled features. The set stores information on enabled flags and metadata about the feature names. A feature vector is serializable to a compact byte representation that is included in Lightning network messages.

func EmptyFeatureVector

func EmptyFeatureVector() *FeatureVector

EmptyFeatureVector returns a feature vector with no bits set.

func NewFeatureVector

func NewFeatureVector(featureVector *RawFeatureVector,
	featureNames map[FeatureBit]string) *FeatureVector

NewFeatureVector constructs a new FeatureVector from a raw feature vector and mapping of feature definitions. If the feature vector argument is nil, a new one will be constructed with no enabled features.

func (*FeatureVector) Clone

func (fv *FeatureVector) Clone() *FeatureVector

Clone copies a feature vector, carrying over its feature bits. The feature names are not copied.

func (*FeatureVector) Features

func (fv *FeatureVector) Features() map[FeatureBit]struct{}

Features returns the set of raw features contained in the feature vector.

func (*FeatureVector) HasFeature

func (fv *FeatureVector) HasFeature(feature FeatureBit) bool

HasFeature returns whether a particular feature is included in the set. The feature can be seen as set either if the bit is set directly OR the queried bit has the same meaning as its corresponding even/odd bit, which is set instead. The second case is because feature bits are generally assigned in pairs where both the even and odd position represent the same feature.

func (*FeatureVector) IsKnown

func (fv *FeatureVector) IsKnown(bit FeatureBit) bool

IsKnown returns whether this feature bit represents a known feature.

func (*FeatureVector) Name

func (fv *FeatureVector) Name(bit FeatureBit) string

Name returns a string identifier for the feature represented by this bit. If the bit does not represent a known feature, this returns a string indicating as such.

func (*FeatureVector) RequiresFeature

func (fv *FeatureVector) RequiresFeature(feature FeatureBit) bool

RequiresFeature returns true if the referenced feature vector *requires* that the given required bit be set. This method can be used with both optional and required feature bits as a parameter.

func (*FeatureVector) UnknownRequiredFeatures

func (fv *FeatureVector) UnknownRequiredFeatures() []FeatureBit

UnknownRequiredFeatures returns a list of feature bits set in the vector that are unknown and in an even bit position. Feature bits with an even index must be known to a node receiving the feature vector in a message.

type FundingCreated

type FundingCreated struct {
	// PendingChannelID serves to uniquely identify the future channel
	// created by the initiated single funder workflow.
	PendingChannelID [32]byte

	// FundingPoint is the outpoint of the funding transaction created by
	// Alice. With this, Bob is able to generate both his version and
	// Alice's version of the commitment transaction.
	FundingPoint wire.OutPoint

	// CommitSig is Alice's signature from Bob's version of the commitment
	// transaction.
	CommitSig Sig

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraData ExtraOpaqueData
}

FundingCreated is sent from Alice (the initiator) to Bob (the responder), once Alice receives Bob's contributions as well as his channel constraints. Once bob receives this message, he'll gain access to an immediately broadcastable commitment transaction and will reply with a signature for Alice's version of the commitment transaction.

func (*FundingCreated) Decode

func (f *FundingCreated) Decode(r io.Reader, pver uint32) error

Decode deserializes the serialized FundingCreated stored in the passed io.Reader into the target FundingCreated using the deserialization rules defined by the passed protocol version.

This is part of the lnwire.Message interface.

func (*FundingCreated) Encode

func (f *FundingCreated) Encode(w io.Writer, pver uint32) error

Encode serializes the target FundingCreated into the passed io.Writer implementation. Serialization will observe the rules defined by the passed protocol version.

This is part of the lnwire.Message interface.

func (*FundingCreated) MsgType

func (f *FundingCreated) MsgType() MessageType

MsgType returns the uint32 code which uniquely identifies this message as a FundingCreated on the wire.

This is part of the lnwire.Message interface.

type FundingError

type FundingError uint8

FundingError represents a set of errors that can be encountered and sent during the funding workflow.

const (
	// ErrMaxPendingChannels is returned by remote peer when the number of
	// active pending channels exceeds their maximum policy limit.
	ErrMaxPendingChannels FundingError = 1

	// ErrSynchronizingChain is returned by a remote peer that receives a
	// channel update or a funding request while it's still syncing to the
	// latest state of the blockchain.
	ErrSynchronizingChain FundingError = 2

	// ErrChanTooLarge is returned by a remote peer that receives a
	// FundingOpen request for a channel that is above their current
	// soft-limit.
	ErrChanTooLarge FundingError = 3
)

func (FundingError) Error

func (e FundingError) Error() string

Error returns the human readable version of the target FundingError.

NOTE: Satisfies the Error interface.

func (FundingError) String

func (e FundingError) String() string

String returns a human readable version of the target FundingError.

type FundingFlag

type FundingFlag uint8

FundingFlag represents the possible bit mask values for the ChannelFlags field within the OpenChannel struct.

const (
	// FFAnnounceChannel is a FundingFlag that when set, indicates the
	// initiator of a funding flow wishes to announce the channel to the
	// greater network.
	FFAnnounceChannel FundingFlag = 1 << iota
)

type FundingLocked

type FundingLocked struct {
	// ChanID is the outpoint of the channel's funding transaction. This
	// can be used to query for the channel in the database.
	ChanID ChannelID

	// NextPerCommitmentPoint is the secret that can be used to revoke the
	// next commitment transaction for the channel.
	NextPerCommitmentPoint *btcec.PublicKey

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraData ExtraOpaqueData
}

FundingLocked is the message that both parties to a new channel creation send once they have observed the funding transaction being confirmed on the blockchain. FundingLocked contains the signatures necessary for the channel participants to advertise the existence of the channel to the rest of the network.

func NewFundingLocked

func NewFundingLocked(cid ChannelID, npcp *btcec.PublicKey) *FundingLocked

NewFundingLocked creates a new FundingLocked message, populating it with the necessary IDs and revocation secret.

func (*FundingLocked) Decode

func (c *FundingLocked) Decode(r io.Reader, pver uint32) error

Decode deserializes the serialized FundingLocked message stored in the passed io.Reader into the target FundingLocked using the deserialization rules defined by the passed protocol version.

This is part of the lnwire.Message interface.

func (*FundingLocked) Encode

func (c *FundingLocked) Encode(w io.Writer, pver uint32) error

Encode serializes the target FundingLocked message into the passed io.Writer implementation. Serialization will observe the rules defined by the passed protocol version.

This is part of the lnwire.Message interface.

func (*FundingLocked) MsgType

func (c *FundingLocked) MsgType() MessageType

MsgType returns the uint32 code which uniquely identifies this message as a FundingLocked message on the wire.

This is part of the lnwire.Message interface.

type FundingSigned

type FundingSigned struct {
	// ChannelPoint is the particular active channel that this
	// FundingSigned is bound to.
	ChanID ChannelID

	// CommitSig is Bob's signature for Alice's version of the commitment
	// transaction.
	CommitSig Sig

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraData ExtraOpaqueData
}

FundingSigned is sent from Bob (the responder) to Alice (the initiator) after receiving the funding outpoint and her signature for Bob's version of the commitment transaction.

func (*FundingSigned) Decode

func (f *FundingSigned) Decode(r io.Reader, pver uint32) error

Decode deserializes the serialized FundingSigned stored in the passed io.Reader into the target FundingSigned using the deserialization rules defined by the passed protocol version.

This is part of the lnwire.Message interface.

func (*FundingSigned) Encode

func (f *FundingSigned) Encode(w io.Writer, pver uint32) error

Encode serializes the target FundingSigned into the passed io.Writer implementation. Serialization will observe the rules defined by the passed protocol version.

This is part of the lnwire.Message interface.

func (*FundingSigned) MsgType

func (f *FundingSigned) MsgType() MessageType

MsgType returns the uint32 code which uniquely identifies this message as a FundingSigned on the wire.

This is part of the lnwire.Message interface.

type GossipTimestampRange

type GossipTimestampRange struct {
	// ChainHash denotes the chain that the sender wishes to restrict the
	// set of received announcements of.
	ChainHash chainhash.Hash

	// FirstTimestamp is the timestamp of the earliest announcement message
	// that should be sent by the receiver.
	FirstTimestamp uint32

	// TimestampRange is the horizon beyond the FirstTimestamp that any
	// announcement messages should be sent for. The receiving node MUST
	// NOT send any announcements that have a timestamp greater than
	// FirstTimestamp + TimestampRange.
	TimestampRange uint32

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraData ExtraOpaqueData
}

GossipTimestampRange is a message that allows the sender to restrict the set of future gossip announcements sent by the receiver. Nodes should send this if they have the gossip-queries feature bit active. Nodes are able to send new GossipTimestampRange messages to replace the prior window.

func NewGossipTimestampRange

func NewGossipTimestampRange() *GossipTimestampRange

NewGossipTimestampRange creates a new empty GossipTimestampRange message.

func (*GossipTimestampRange) Decode

func (g *GossipTimestampRange) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized GossipTimestampRange message stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*GossipTimestampRange) Encode

func (g *GossipTimestampRange) Encode(w io.Writer, pver uint32) error

Encode serializes the target GossipTimestampRange into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*GossipTimestampRange) MsgType

func (g *GossipTimestampRange) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

type Init

type Init struct {
	// GlobalFeatures is a legacy feature vector used for backwards
	// compatibility with older nodes. Any features defined here should be
	// merged with those presented in Features.
	GlobalFeatures *RawFeatureVector

	// Features is a feature vector containing the features supported by
	// the remote node.
	//
	// NOTE: Older nodes may place some features in GlobalFeatures, but all
	// new features are to be added in Features. When handling an Init
	// message, any GlobalFeatures should be merged into the unified
	// Features field.
	Features *RawFeatureVector

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraData ExtraOpaqueData
}

Init is the first message reveals the features supported or required by this node. Nodes wait for receipt of the other's features to simplify error diagnosis where features are incompatible. Each node MUST wait to receive init before sending any other messages.

func NewInitMessage

func NewInitMessage(gf *RawFeatureVector, f *RawFeatureVector) *Init

NewInitMessage creates new instance of init message object.

func (*Init) Decode

func (msg *Init) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized Init message stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*Init) Encode

func (msg *Init) Encode(w io.Writer, pver uint32) error

Encode serializes the target Init into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*Init) MsgType

func (msg *Init) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

type InvalidOnionPayload

type InvalidOnionPayload struct {
	// Type is the TLV type that caused the specific failure.
	Type uint64

	// Offset is the byte offset within the payload where the failure
	// occurred.
	Offset uint16
}

InvalidOnionPayload is returned if the hop could not process the TLV payload enclosed in the onion.

func NewInvalidOnionPayload

func NewInvalidOnionPayload(typ uint64, offset uint16) *InvalidOnionPayload

NewInvalidOnionPayload initializes a new InvalidOnionPayload failure.

func (*InvalidOnionPayload) Code

func (f *InvalidOnionPayload) Code() FailCode

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*InvalidOnionPayload) Decode

func (f *InvalidOnionPayload) Decode(r io.Reader, pver uint32) error

Decode decodes the failure from bytes stream.

NOTE: Part of the Serializable interface.

func (*InvalidOnionPayload) Encode

func (f *InvalidOnionPayload) Encode(w io.Writer, pver uint32) error

Encode writes the failure in bytes stream.

NOTE: Part of the Serializable interface.

func (*InvalidOnionPayload) Error

func (f *InvalidOnionPayload) Error() string

Returns a human readable string describing the target FailureMessage.

NOTE: Implements the error interface.

type Message

type Message interface {
	Serializable
	MsgType() MessageType
}

Message is an interface that defines a lightning wire protocol message. The interface is general in order to allow implementing types full control over the representation of its data.

func ReadMessage

func ReadMessage(r io.Reader, pver uint32) (Message, error)

ReadMessage reads, validates, and parses the next Lightning message from r for the provided protocol version.

type MessageType

type MessageType uint16

MessageType is the unique 2 byte big-endian integer that indicates the type of message on the wire. All messages have a very simple header which consists simply of 2-byte message type. We omit a length field, and checksum as the Lightning Protocol is intended to be encapsulated within a confidential+authenticated cryptographic messaging protocol.

func (MessageType) String

func (t MessageType) String() string

String return the string representation of message type.

type MilliSatoshi

type MilliSatoshi uint64

MilliSatoshi are the native unit of the Lightning Network. A milli-satoshi is simply 1/1000th of a satoshi. There are 1000 milli-satoshis in a single satoshi. Within the network, all HTLC payments are denominated in milli-satoshis. As milli-satoshis aren't deliverable on the native blockchain, before settling to broadcasting, the values are rounded down to the nearest satoshi.

func NewMSatFromSatoshis

func NewMSatFromSatoshis(sat vclutil.Amount) MilliSatoshi

NewMSatFromSatoshis creates a new MilliSatoshi instance from a target amount of satoshis.

func (MilliSatoshi) String

func (m MilliSatoshi) String() string

String returns the string representation of the mSAT amount.

func (MilliSatoshi) ToBTC

func (m MilliSatoshi) ToBTC() float64

ToBTC converts the target MilliSatoshi amount to its corresponding value when expressed in BTC.

func (MilliSatoshi) ToSatoshis

func (m MilliSatoshi) ToSatoshis() vclutil.Amount

ToSatoshis converts the target MilliSatoshi amount to satoshis. Simply, this sheds a factor of 1000 from the mSAT amount in order to convert it to SAT.

type NetAddress

type NetAddress struct {
	// IdentityKey is the long-term static public key for a node. This node is
	// used throughout the network as a node's identity key. It is used to
	// authenticate any data sent to the network on behalf of the node, and
	// additionally to establish a confidential+authenticated connection with
	// the node.
	IdentityKey *btcec.PublicKey

	// Address is the IP address and port of the node. This is left
	// general so that multiple implementations can be used.
	Address net.Addr

	// ChainNet is the Bitcoin network this node is associated with.
	// TODO(roasbeef): make a slice in the future for multi-chain
	ChainNet wire.BitcoinNet
}

NetAddress represents information pertaining to the identity and network reachability of a peer. Information stored includes the node's identity public key for establishing a confidential+authenticated connection, the service bits it supports, and a TCP address the node is reachable at.

TODO(roasbeef): merge with LinkNode in some fashion

func (*NetAddress) Network

func (n *NetAddress) Network() string

Network returns the name of the network this address is bound to.

This part of the net.Addr interface.

func (*NetAddress) String

func (n *NetAddress) String() string

String returns a human readable string describing the target NetAddress. The current string format is: <pubkey>@host.

This part of the net.Addr interface.

type NodeAlias

type NodeAlias [32]byte

NodeAlias is a hex encoded UTF-8 string that may be displayed as an alternative to the node's ID. Notice that aliases are not unique and may be freely chosen by the node operators.

func NewNodeAlias

func NewNodeAlias(s string) (NodeAlias, error)

NewNodeAlias creates a new instance of a NodeAlias. Verification is performed on the passed string to ensure it meets the alias requirements.

func (NodeAlias) String

func (n NodeAlias) String() string

String returns a utf8 string representation of the alias bytes.

type NodeAnnouncement

type NodeAnnouncement struct {
	// Signature is used to prove the ownership of node id.
	Signature Sig

	// Features is the list of protocol features this node supports.
	Features *RawFeatureVector

	// Timestamp allows ordering in the case of multiple announcements.
	Timestamp uint32

	// NodeID is a public key which is used as node identification.
	NodeID [33]byte

	// RGBColor is used to customize their node's appearance in maps and
	// graphs
	RGBColor color.RGBA

	// Alias is used to customize their node's appearance in maps and
	// graphs
	Alias NodeAlias

	// Address includes two specification fields: 'ipv6' and 'port' on
	// which the node is accepting incoming connections.
	Addresses []net.Addr

	// ExtraOpaqueData is the set of data that was appended to this
	// message, some of which we may not actually know how to iterate or
	// parse. By holding onto this data, we ensure that we're able to
	// properly validate the set of signatures that cover these new fields,
	// and ensure we're able to make upgrades to the network in a forwards
	// compatible manner.
	ExtraOpaqueData ExtraOpaqueData
}

NodeAnnouncement message is used to announce the presence of a Lightning node and also to signal that the node is accepting incoming connections. Each NodeAnnouncement authenticating the advertised information within the announcement via a signature using the advertised node pubkey.

func (*NodeAnnouncement) DataToSign

func (a *NodeAnnouncement) DataToSign() ([]byte, error)

DataToSign returns the part of the message that should be signed.

func (*NodeAnnouncement) Decode

func (a *NodeAnnouncement) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized NodeAnnouncement stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*NodeAnnouncement) Encode

func (a *NodeAnnouncement) Encode(w io.Writer, pver uint32) error

Encode serializes the target NodeAnnouncement into the passed io.Writer observing the protocol version specified.

func (*NodeAnnouncement) MsgType

func (a *NodeAnnouncement) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

type OpaqueReason

type OpaqueReason []byte

OpaqueReason is an opaque encrypted byte slice that encodes the exact failure reason and additional some supplemental data. The contents of this slice can only be decrypted by the sender of the original HTLC.

type OpenChannel

type OpenChannel struct {
	// ChainHash is the target chain that the initiator wishes to open a
	// channel within.
	ChainHash chainhash.Hash

	// PendingChannelID serves to uniquely identify the future channel
	// created by the initiated single funder workflow.
	PendingChannelID [32]byte

	// FundingAmount is the amount of satoshis that the initiator of the
	// channel wishes to use as the total capacity of the channel. The
	// initial balance of the funding will be this value minus the push
	// amount (if set).
	FundingAmount vclutil.Amount

	// PushAmount is the value that the initiating party wishes to "push"
	// to the responding as part of the first commitment state. If the
	// responder accepts, then this will be their initial balance.
	PushAmount MilliSatoshi

	// DustLimit is the specific dust limit the sender of this message
	// would like enforced on their version of the commitment transaction.
	// Any output below this value will be "trimmed" from the commitment
	// transaction, with the amount of the HTLC going to dust.
	DustLimit vclutil.Amount

	// MaxValueInFlight represents the maximum amount of coins that can be
	// pending within the channel at any given time. If the amount of funds
	// in limbo exceeds this amount, then the channel will be failed.
	MaxValueInFlight MilliSatoshi

	// ChannelReserve is the amount of BTC that the receiving party MUST
	// maintain a balance above at all times. This is a safety mechanism to
	// ensure that both sides always have skin in the game during the
	// channel's lifetime.
	ChannelReserve vclutil.Amount

	// HtlcMinimum is the smallest HTLC that the sender of this message
	// will accept.
	HtlcMinimum MilliSatoshi

	// FeePerKiloWeight is the initial fee rate that the initiator suggests
	// for both commitment transaction. This value is expressed in sat per
	// kilo-weight.
	//
	// TODO(halseth): make SatPerKWeight when fee estimation is in own
	// package. Currently this will cause an import cycle.
	FeePerKiloWeight uint32

	// CsvDelay is the number of blocks to use for the relative time lock
	// in the pay-to-self output of both commitment transactions.
	CsvDelay uint16

	// MaxAcceptedHTLCs is the total number of incoming HTLC's that the
	// sender of this channel will accept.
	MaxAcceptedHTLCs uint16

	// FundingKey is the key that should be used on behalf of the sender
	// within the 2-of-2 multi-sig output that it contained within the
	// funding transaction.
	FundingKey *btcec.PublicKey

	// RevocationPoint is the base revocation point for the sending party.
	// Any commitment transaction belonging to the receiver of this message
	// should use this key and their per-commitment point to derive the
	// revocation key for the commitment transaction.
	RevocationPoint *btcec.PublicKey

	// PaymentPoint is the base payment point for the sending party. This
	// key should be combined with the per commitment point for a
	// particular commitment state in order to create the key that should
	// be used in any output that pays directly to the sending party, and
	// also within the HTLC covenant transactions.
	PaymentPoint *btcec.PublicKey

	// DelayedPaymentPoint is the delay point for the sending party. This
	// key should be combined with the per commitment point to derive the
	// keys that are used in outputs of the sender's commitment transaction
	// where they claim funds.
	DelayedPaymentPoint *btcec.PublicKey

	// HtlcPoint is the base point used to derive the set of keys for this
	// party that will be used within the HTLC public key scripts. This
	// value is combined with the receiver's revocation base point in order
	// to derive the keys that are used within HTLC scripts.
	HtlcPoint *btcec.PublicKey

	// FirstCommitmentPoint is the first commitment point for the sending
	// party. This value should be combined with the receiver's revocation
	// base point in order to derive the revocation keys that are placed
	// within the commitment transaction of the sender.
	FirstCommitmentPoint *btcec.PublicKey

	// ChannelFlags is a bit-field which allows the initiator of the
	// channel to specify further behavior surrounding the channel.
	// Currently, the least significant bit of this bit field indicates the
	// initiator of the channel wishes to advertise this channel publicly.
	ChannelFlags FundingFlag

	// UpfrontShutdownScript is the script to which the channel funds should
	// be paid when mutually closing the channel. This field is optional, and
	// and has a length prefix, so a zero will be written if it is not set
	// and its length followed by the script will be written if it is set.
	UpfrontShutdownScript DeliveryAddress

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	//
	// NOTE: Since the upfront shutdown script MUST be present (though can
	// be zero-length) if any TLV data is available, the script will be
	// extracted and removed from this blob when decoding. ExtraData will
	// contain all TLV records _except_ the DeliveryAddress record in that
	// case.
	ExtraData ExtraOpaqueData
}

OpenChannel is the message Alice sends to Bob if we should like to create a channel with Bob where she's the sole provider of funds to the channel. Single funder channels simplify the initial funding workflow, are supported by nodes backed by SPV Bitcoin clients, and have a simpler security models than dual funded channels.

func (*OpenChannel) Decode

func (o *OpenChannel) Decode(r io.Reader, pver uint32) error

Decode deserializes the serialized OpenChannel stored in the passed io.Reader into the target OpenChannel using the deserialization rules defined by the passed protocol version.

This is part of the lnwire.Message interface.

func (*OpenChannel) Encode

func (o *OpenChannel) Encode(w io.Writer, pver uint32) error

Encode serializes the target OpenChannel into the passed io.Writer implementation. Serialization will observe the rules defined by the passed protocol version.

This is part of the lnwire.Message interface.

func (*OpenChannel) MsgType

func (o *OpenChannel) MsgType() MessageType

MsgType returns the MessageType code which uniquely identifies this message as an OpenChannel on the wire.

This is part of the lnwire.Message interface.

type Ping

type Ping struct {
	// NumPongBytes is the number of bytes the pong response to this
	// message should carry.
	NumPongBytes uint16

	// PaddingBytes is a set of opaque bytes used to pad out this ping
	// message. Using this field in conjunction to the one above, it's
	// possible for node to generate fake cover traffic.
	PaddingBytes PingPayload
}

Ping defines a message which is sent by peers periodically to determine if the connection is still valid. Each ping message carries the number of bytes to pad the pong response with, and also a number of bytes to be ignored at the end of the ping message (which is padding).

func NewPing

func NewPing(numBytes uint16) *Ping

NewPing returns a new Ping message.

func (*Ping) Decode

func (p *Ping) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized Ping message stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*Ping) Encode

func (p *Ping) Encode(w io.Writer, pver uint32) error

Encode serializes the target Ping into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*Ping) MsgType

func (p *Ping) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

type PingPayload

type PingPayload []byte

PingPayload is a set of opaque bytes used to pad out a ping message.

type PkScript

type PkScript []byte

PkScript is simple type definition which represents a raw serialized public key script.

type Pong

type Pong struct {
	// PongBytes is a set of opaque bytes that corresponds to the
	// NumPongBytes defined in the ping message that this pong is
	// replying to.
	PongBytes PongPayload
}

Pong defines a message which is the direct response to a received Ping message. A Pong reply indicates that a connection is still active. The Pong reply to a Ping message should contain the nonce carried in the original Pong message.

func NewPong

func NewPong(pongBytes []byte) *Pong

NewPong returns a new Pong message.

func (*Pong) Decode

func (p *Pong) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized Pong message stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*Pong) Encode

func (p *Pong) Encode(w io.Writer, pver uint32) error

Encode serializes the target Pong into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*Pong) MsgType

func (p *Pong) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

type PongPayload

type PongPayload []byte

PongPayload is a set of opaque bytes sent in response to a ping message.

type QueryChannelRange

type QueryChannelRange struct {
	// ChainHash denotes the target chain that we're trying to synchronize
	// channel graph state for.
	ChainHash chainhash.Hash

	// FirstBlockHeight is the first block in the query range. The
	// responder should send all new short channel IDs from this block
	// until this block plus the specified number of blocks.
	FirstBlockHeight uint32

	// NumBlocks is the number of blocks beyond the first block that short
	// channel ID's should be sent for.
	NumBlocks uint32

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraData ExtraOpaqueData
}

QueryChannelRange is a message sent by a node in order to query the receiving node of the set of open channel they know of with short channel ID's after the specified block height, capped at the number of blocks beyond that block height. This will be used by nodes upon initial connect to synchronize their views of the network.

func NewQueryChannelRange

func NewQueryChannelRange() *QueryChannelRange

NewQueryChannelRange creates a new empty QueryChannelRange message.

func (*QueryChannelRange) Decode

func (q *QueryChannelRange) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized QueryChannelRange message stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*QueryChannelRange) Encode

func (q *QueryChannelRange) Encode(w io.Writer, pver uint32) error

Encode serializes the target QueryChannelRange into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*QueryChannelRange) LastBlockHeight

func (q *QueryChannelRange) LastBlockHeight() uint32

LastBlockHeight returns the last block height covered by the range of a QueryChannelRange message.

func (*QueryChannelRange) MsgType

func (q *QueryChannelRange) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

type QueryShortChanIDs

type QueryShortChanIDs struct {
	// ChainHash denotes the target chain that we're querying for the
	// channel ID's of.
	ChainHash chainhash.Hash

	// EncodingType is a signal to the receiver of the message that
	// indicates exactly how the set of short channel ID's that follow have
	// been encoded.
	EncodingType ShortChanIDEncoding

	// ShortChanIDs is a slice of decoded short channel ID's.
	ShortChanIDs []ShortChannelID

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraData ExtraOpaqueData
	// contains filtered or unexported fields
}

QueryShortChanIDs is a message that allows the sender to query a set of channel announcement and channel update messages that correspond to the set of encoded short channel ID's. The encoding of the short channel ID's is detailed in the query message ensuring that the receiver knows how to properly decode each encode short channel ID which may be encoded using a compression format. The receiver should respond with a series of channel announcement and channel updates, finally sending a ReplyShortChanIDsEnd message.

func NewQueryShortChanIDs

func NewQueryShortChanIDs(h chainhash.Hash, e ShortChanIDEncoding,
	s []ShortChannelID) *QueryShortChanIDs

NewQueryShortChanIDs creates a new QueryShortChanIDs message.

func (*QueryShortChanIDs) Decode

func (q *QueryShortChanIDs) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized QueryShortChanIDs message stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*QueryShortChanIDs) Encode

func (q *QueryShortChanIDs) Encode(w io.Writer, pver uint32) error

Encode serializes the target QueryShortChanIDs into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*QueryShortChanIDs) MsgType

func (q *QueryShortChanIDs) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

type RawFeatureVector

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

RawFeatureVector represents a set of feature bits as defined in BOLT-09. A RawFeatureVector itself just stores a set of bit flags but can be used to construct a FeatureVector which binds meaning to each bit. Feature vectors can be serialized and deserialized to/from a byte representation that is transmitted in Lightning network messages.

func NewRawFeatureVector

func NewRawFeatureVector(bits ...FeatureBit) *RawFeatureVector

NewRawFeatureVector creates a feature vector with all of the feature bits given as arguments enabled.

func (*RawFeatureVector) Clone

func (fv *RawFeatureVector) Clone() *RawFeatureVector

Clone makes a copy of a feature vector.

func (*RawFeatureVector) Decode

func (fv *RawFeatureVector) Decode(r io.Reader) error

Decode reads the feature vector from its byte representation. Every feature is encoded as a bit, and the bit vector is serialized using the least number of bytes. Since the bit vector length is variable, the first two bytes of the serialization represent the length.

func (*RawFeatureVector) DecodeBase256

func (fv *RawFeatureVector) DecodeBase256(r io.Reader, length int) error

DecodeBase256 reads the feature vector from its base256 representation. Every feature encoded as a bit, and the bit vector is serialized using the least number of bytes.

func (*RawFeatureVector) DecodeBase32

func (fv *RawFeatureVector) DecodeBase32(r io.Reader, length int) error

DecodeBase32 reads the feature vector from its base32 representation. Every feature encoded as a bit, and the bit vector is serialized using the least number of bytes.

func (*RawFeatureVector) Encode

func (fv *RawFeatureVector) Encode(w io.Writer) error

Encode writes the feature vector in byte representation. Every feature encoded as a bit, and the bit vector is serialized using the least number of bytes. Since the bit vector length is variable, the first two bytes of the serialization represent the length.

func (*RawFeatureVector) EncodeBase256

func (fv *RawFeatureVector) EncodeBase256(w io.Writer) error

EncodeBase256 writes the feature vector in base256 representation. Every feature is encoded as a bit, and the bit vector is serialized using the least number of bytes.

func (*RawFeatureVector) EncodeBase32

func (fv *RawFeatureVector) EncodeBase32(w io.Writer) error

EncodeBase32 writes the feature vector in base32 representation. Every feature is encoded as a bit, and the bit vector is serialized using the least number of bytes.

func (*RawFeatureVector) IsSet

func (fv *RawFeatureVector) IsSet(feature FeatureBit) bool

IsSet returns whether a particular feature bit is enabled in the vector.

func (*RawFeatureVector) Merge

func (fv *RawFeatureVector) Merge(other *RawFeatureVector) error

Merges sets all feature bits in other on the receiver's feature vector.

func (*RawFeatureVector) SafeSet

func (fv *RawFeatureVector) SafeSet(feature FeatureBit) error

SafeSet sets the chosen feature bit in the feature vector, but returns an error if the opposing feature bit is already set. This ensures both that we are creating properly structured feature vectors, and in some cases, that peers are sending properly encoded ones, i.e. it can't be both optional and required.

func (*RawFeatureVector) SerializeSize

func (fv *RawFeatureVector) SerializeSize() int

SerializeSize returns the number of bytes needed to represent feature vector in byte format.

func (*RawFeatureVector) SerializeSize32

func (fv *RawFeatureVector) SerializeSize32() int

SerializeSize32 returns the number of bytes needed to represent feature vector in base32 format.

func (*RawFeatureVector) Set

func (fv *RawFeatureVector) Set(feature FeatureBit)

Set marks a feature as enabled in the vector.

func (*RawFeatureVector) Unset

func (fv *RawFeatureVector) Unset(feature FeatureBit)

Unset marks a feature as disabled in the vector.

type ReplyChannelRange

type ReplyChannelRange struct {
	// ChainHash denotes the target chain that we're trying to synchronize
	// channel graph state for.
	ChainHash chainhash.Hash

	// FirstBlockHeight is the first block in the query range. The
	// responder should send all new short channel IDs from this block
	// until this block plus the specified number of blocks.
	FirstBlockHeight uint32

	// NumBlocks is the number of blocks beyond the first block that short
	// channel ID's should be sent for.
	NumBlocks uint32

	// Complete denotes if this is the conclusion of the set of streaming
	// responses to the original query.
	Complete uint8

	// EncodingType is a signal to the receiver of the message that
	// indicates exactly how the set of short channel ID's that follow have
	// been encoded.
	EncodingType ShortChanIDEncoding

	// ShortChanIDs is a slice of decoded short channel ID's.
	ShortChanIDs []ShortChannelID

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraData ExtraOpaqueData
	// contains filtered or unexported fields
}

ReplyChannelRange is the response to the QueryChannelRange message. It includes the original query, and the next streaming chunk of encoded short channel ID's as the response. We'll also include a byte that indicates if this is the last query in the message.

func NewReplyChannelRange

func NewReplyChannelRange() *ReplyChannelRange

NewReplyChannelRange creates a new empty ReplyChannelRange message.

func (*ReplyChannelRange) Decode

func (c *ReplyChannelRange) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized ReplyChannelRange message stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*ReplyChannelRange) Encode

func (c *ReplyChannelRange) Encode(w io.Writer, pver uint32) error

Encode serializes the target ReplyChannelRange into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*ReplyChannelRange) LastBlockHeight

func (c *ReplyChannelRange) LastBlockHeight() uint32

LastBlockHeight returns the last block height covered by the range of a QueryChannelRange message.

func (*ReplyChannelRange) MsgType

func (c *ReplyChannelRange) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

type ReplyShortChanIDsEnd

type ReplyShortChanIDsEnd struct {
	// ChainHash denotes the target chain that we're respond to a short
	// chan ID query for.
	ChainHash chainhash.Hash

	// Complete will be set to 0 if we don't know of the chain that the
	// remote peer sent their query for. Otherwise, we'll set this to 1 in
	// order to indicate that we've sent all known responses for the prior
	// set of short chan ID's in the corresponding QueryShortChanIDs
	// message.
	Complete uint8

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraData ExtraOpaqueData
}

ReplyShortChanIDsEnd is a message that marks the end of a streaming message response to an initial QueryShortChanIDs message. This marks that the receiver of the original QueryShortChanIDs for the target chain has either sent all adequate responses it knows of, or doesn't know of any short chan ID's for the target chain.

func NewReplyShortChanIDsEnd

func NewReplyShortChanIDsEnd() *ReplyShortChanIDsEnd

NewReplyShortChanIDsEnd creates a new empty ReplyShortChanIDsEnd message.

func (*ReplyShortChanIDsEnd) Decode

func (c *ReplyShortChanIDsEnd) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized ReplyShortChanIDsEnd message stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*ReplyShortChanIDsEnd) Encode

func (c *ReplyShortChanIDsEnd) Encode(w io.Writer, pver uint32) error

Encode serializes the target ReplyShortChanIDsEnd into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*ReplyShortChanIDsEnd) MsgType

func (c *ReplyShortChanIDsEnd) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

type RevokeAndAck

type RevokeAndAck struct {
	// ChanID uniquely identifies to which currently active channel this
	// RevokeAndAck applies to.
	ChanID ChannelID

	// Revocation is the preimage to the revocation hash of the now prior
	// commitment transaction.
	Revocation [32]byte

	// NextRevocationKey is the next commitment point which should be used
	// for the next commitment transaction the remote peer creates for us.
	// This, in conjunction with revocation base point will be used to
	// create the proper revocation key used within the commitment
	// transaction.
	NextRevocationKey *btcec.PublicKey

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraData ExtraOpaqueData
}

RevokeAndAck is sent by either side once a CommitSig message has been received, and validated. This message serves to revoke the prior commitment transaction, which was the most up to date version until a CommitSig message referencing the specified ChannelPoint was received. Additionally, this message also piggyback's the next revocation hash that Alice should use when constructing the Bob's version of the next commitment transaction (which would be done before sending a CommitSig message). This piggybacking allows Alice to send the next CommitSig message modifying Bob's commitment transaction without first asking for a revocation hash initially.

func NewRevokeAndAck

func NewRevokeAndAck() *RevokeAndAck

NewRevokeAndAck creates a new RevokeAndAck message.

func (*RevokeAndAck) Decode

func (c *RevokeAndAck) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized RevokeAndAck message stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*RevokeAndAck) Encode

func (c *RevokeAndAck) Encode(w io.Writer, pver uint32) error

Encode serializes the target RevokeAndAck into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*RevokeAndAck) MsgType

func (c *RevokeAndAck) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

func (*RevokeAndAck) TargetChanID

func (c *RevokeAndAck) TargetChanID() ChannelID

TargetChanID returns the channel id of the link for which this message is intended.

NOTE: Part of peer.LinkUpdater interface.

type Serializable

type Serializable interface {
	// Decode reads the bytes stream and converts it to the object.
	Decode(io.Reader, uint32) error

	// Encode converts object to the bytes stream and write it into the
	// writer.
	Encode(io.Writer, uint32) error
}

Serializable is an interface which defines a lightning wire serializable object.

type ShortChanIDEncoding

type ShortChanIDEncoding uint8

ShortChanIDEncoding is an enum-like type that represents exactly how a set of short channel ID's is encoded on the wire. The set of encodings allows us to take advantage of the structure of a list of short channel ID's to achieving a high degree of compression.

const (
	// EncodingSortedPlain signals that the set of short channel ID's is
	// encoded using the regular encoding, in a sorted order.
	EncodingSortedPlain ShortChanIDEncoding = 0

	// EncodingSortedZlib signals that the set of short channel ID's is
	// encoded by first sorting the set of channel ID's, as then
	// compressing them using zlib.
	EncodingSortedZlib ShortChanIDEncoding = 1
)

type ShortChannelID

type ShortChannelID struct {
	// BlockHeight is the height of the block where funding transaction
	// located.
	//
	// NOTE: This field is limited to 3 bytes.
	BlockHeight uint32

	// TxIndex is a position of funding transaction within a block.
	//
	// NOTE: This field is limited to 3 bytes.
	TxIndex uint32

	// TxPosition indicating transaction output which pays to the channel.
	TxPosition uint16
}

ShortChannelID represents the set of data which is needed to retrieve all necessary data to validate the channel existence.

func NewShortChanIDFromInt

func NewShortChanIDFromInt(chanID uint64) ShortChannelID

NewShortChanIDFromInt returns a new ShortChannelID which is the decoded version of the compact channel ID encoded within the uint64. The format of the compact channel ID is as follows: 3 bytes for the block height, 3 bytes for the transaction index, and 2 bytes for the output index.

func (ShortChannelID) String

func (c ShortChannelID) String() string

String generates a human-readable representation of the channel ID.

func (ShortChannelID) ToUint64

func (c ShortChannelID) ToUint64() uint64

ToUint64 converts the ShortChannelID into a compact format encoded within a uint64 (8 bytes).

type Shutdown

type Shutdown struct {
	// ChannelID serves to identify which channel is to be closed.
	ChannelID ChannelID

	// Address is the script to which the channel funds will be paid.
	Address DeliveryAddress

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraData ExtraOpaqueData
}

Shutdown is sent by either side in order to initiate the cooperative closure of a channel. This message is sparse as both sides implicitly have the information necessary to construct a transaction that will send the settled funds of both parties to the final delivery addresses negotiated during the funding workflow.

func NewShutdown

func NewShutdown(cid ChannelID, addr DeliveryAddress) *Shutdown

NewShutdown creates a new Shutdown message.

func (*Shutdown) Decode

func (s *Shutdown) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized Shutdown stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*Shutdown) Encode

func (s *Shutdown) Encode(w io.Writer, pver uint32) error

Encode serializes the target Shutdown into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*Shutdown) MsgType

func (s *Shutdown) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

type Sig

type Sig [64]byte

Sig is a fixed-sized ECDSA signature. Unlike Bitcoin, we use fixed sized signatures on the wire, instead of DER encoded signatures. This type provides several methods to convert to/from a regular Bitcoin DER encoded signature (raw bytes and *btcec.Signature).

func NewSigFromRawSignature

func NewSigFromRawSignature(sig []byte) (Sig, error)

NewSigFromRawSignature returns a Sig from a Bitcoin raw signature encoded in the canonical DER encoding.

func NewSigFromSignature

func NewSigFromSignature(e input.Signature) (Sig, error)

NewSigFromSignature creates a new signature as used on the wire, from an existing btcec.Signature.

func (*Sig) ToSignature

func (b *Sig) ToSignature() (*btcec.Signature, error)

ToSignature converts the fixed-sized signature to a btcec.Signature objects which can be used for signature validation checks.

func (*Sig) ToSignatureBytes

func (b *Sig) ToSignatureBytes() []byte

ToSignatureBytes serializes the target fixed-sized signature into the raw bytes of a DER encoding.

type UnknownMessage

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

UnknownMessage is an implementation of the error interface that allows the creation of an error in response to an unknown message.

func (*UnknownMessage) Error

func (u *UnknownMessage) Error() string

Error returns a human readable string describing the error.

This is part of the error interface.

type UpdateAddHTLC

type UpdateAddHTLC struct {
	// ChanID is the particular active channel that this UpdateAddHTLC is
	// bound to.
	ChanID ChannelID

	// ID is the identification server for this HTLC. This value is
	// explicitly included as it allows nodes to survive single-sided
	// restarts. The ID value for this sides starts at zero, and increases
	// with each offered HTLC.
	ID uint64

	// Amount is the amount of millisatoshis this HTLC is worth.
	Amount MilliSatoshi

	// PaymentHash is the payment hash to be included in the HTLC this
	// request creates. The pre-image to this HTLC must be revealed by the
	// upstream peer in order to fully settle the HTLC.
	PaymentHash [32]byte

	// Expiry is the number of blocks after which this HTLC should expire.
	// It is the receiver's duty to ensure that the outgoing HTLC has a
	// sufficient expiry value to allow her to redeem the incoming HTLC.
	Expiry uint32

	// OnionBlob is the raw serialized mix header used to route an HTLC in
	// a privacy-preserving manner. The mix header is defined currently to
	// be parsed as a 4-tuple: (groupElement, routingInfo, headerMAC,
	// body).  First the receiving node should use the groupElement, and
	// its current onion key to derive a shared secret with the source.
	// Once the shared secret has been derived, the headerMAC should be
	// checked FIRST. Note that the MAC only covers the routingInfo field.
	// If the MAC matches, and the shared secret is fresh, then the node
	// should strip off a layer of encryption, exposing the next hop to be
	// used in the subsequent UpdateAddHTLC message.
	OnionBlob [OnionPacketSize]byte

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraData ExtraOpaqueData
}

UpdateAddHTLC is the message sent by Alice to Bob when she wishes to add an HTLC to his remote commitment transaction. In addition to information detailing the value, the ID, expiry, and the onion blob is also included which allows Bob to derive the next hop in the route. The HTLC added by this message is to be added to the remote node's "pending" HTLC's. A subsequent CommitSig message will move the pending HTLC to the newly created commitment transaction, marking them as "staged".

func NewUpdateAddHTLC

func NewUpdateAddHTLC() *UpdateAddHTLC

NewUpdateAddHTLC returns a new empty UpdateAddHTLC message.

func (*UpdateAddHTLC) Decode

func (c *UpdateAddHTLC) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized UpdateAddHTLC message stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*UpdateAddHTLC) Encode

func (c *UpdateAddHTLC) Encode(w io.Writer, pver uint32) error

Encode serializes the target UpdateAddHTLC into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*UpdateAddHTLC) MsgType

func (c *UpdateAddHTLC) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

func (*UpdateAddHTLC) TargetChanID

func (c *UpdateAddHTLC) TargetChanID() ChannelID

TargetChanID returns the channel id of the link for which this message is intended.

NOTE: Part of peer.LinkUpdater interface.

type UpdateFailHTLC

type UpdateFailHTLC struct {
	// ChanIDPoint is the particular active channel that this
	// UpdateFailHTLC is bound to.
	ChanID ChannelID

	// ID references which HTLC on the remote node's commitment transaction
	// has timed out.
	ID uint64

	// Reason is an onion-encrypted blob that details why the HTLC was
	// failed. This blob is only fully decryptable by the initiator of the
	// HTLC message.
	Reason OpaqueReason

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraData ExtraOpaqueData
}

UpdateFailHTLC is sent by Alice to Bob in order to remove a previously added HTLC. Upon receipt of an UpdateFailHTLC the HTLC should be removed from the next commitment transaction, with the UpdateFailHTLC propagated backwards in the route to fully undo the HTLC.

func (*UpdateFailHTLC) Decode

func (c *UpdateFailHTLC) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized UpdateFailHTLC message stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*UpdateFailHTLC) Encode

func (c *UpdateFailHTLC) Encode(w io.Writer, pver uint32) error

Encode serializes the target UpdateFailHTLC into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*UpdateFailHTLC) MsgType

func (c *UpdateFailHTLC) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

func (*UpdateFailHTLC) TargetChanID

func (c *UpdateFailHTLC) TargetChanID() ChannelID

TargetChanID returns the channel id of the link for which this message is intended.

NOTE: Part of peer.LinkUpdater interface.

type UpdateFailMalformedHTLC

type UpdateFailMalformedHTLC struct {
	// ChanID is the particular active channel that this
	// UpdateFailMalformedHTLC is bound to.
	ChanID ChannelID

	// ID references which HTLC on the remote node's commitment transaction
	// has timed out.
	ID uint64

	// ShaOnionBlob hash of the onion blob on which can't be parsed by the
	// node in the payment path.
	ShaOnionBlob [sha256.Size]byte

	// FailureCode the exact reason why onion blob haven't been parsed.
	FailureCode FailCode

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraData ExtraOpaqueData
}

UpdateFailMalformedHTLC is sent by either the payment forwarder or by payment receiver to the payment sender in order to notify it that the onion blob can't be parsed. For that reason we send this message instead of obfuscate the onion failure.

func (*UpdateFailMalformedHTLC) Decode

func (c *UpdateFailMalformedHTLC) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized UpdateFailMalformedHTLC message stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*UpdateFailMalformedHTLC) Encode

func (c *UpdateFailMalformedHTLC) Encode(w io.Writer, pver uint32) error

Encode serializes the target UpdateFailMalformedHTLC into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*UpdateFailMalformedHTLC) MsgType

func (c *UpdateFailMalformedHTLC) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

func (*UpdateFailMalformedHTLC) TargetChanID

func (c *UpdateFailMalformedHTLC) TargetChanID() ChannelID

TargetChanID returns the channel id of the link for which this message is intended.

NOTE: Part of peer.LinkUpdater interface.

type UpdateFee

type UpdateFee struct {
	// ChanID is the channel that this UpdateFee is meant for.
	ChanID ChannelID

	// FeePerKw is the fee-per-kw on commit transactions that the sender of
	// this message wants to use for this channel.
	//
	// TODO(halseth): make SatPerKWeight when fee estimation is moved to
	// own package. Currently this will cause an import cycle.
	FeePerKw uint32

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraData ExtraOpaqueData
}

UpdateFee is the message the channel initiator sends to the other peer if the channel commitment fee needs to be updated.

func NewUpdateFee

func NewUpdateFee(chanID ChannelID, feePerKw uint32) *UpdateFee

NewUpdateFee creates a new UpdateFee message.

func (*UpdateFee) Decode

func (c *UpdateFee) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized UpdateFee message stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*UpdateFee) Encode

func (c *UpdateFee) Encode(w io.Writer, pver uint32) error

Encode serializes the target UpdateFee into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*UpdateFee) MsgType

func (c *UpdateFee) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

func (*UpdateFee) TargetChanID

func (c *UpdateFee) TargetChanID() ChannelID

TargetChanID returns the channel id of the link for which this message is intended.

NOTE: Part of peer.LinkUpdater interface.

type UpdateFulfillHTLC

type UpdateFulfillHTLC struct {
	// ChanID references an active channel which holds the HTLC to be
	// settled.
	ChanID ChannelID

	// ID denotes the exact HTLC stage within the receiving node's
	// commitment transaction to be removed.
	ID uint64

	// PaymentPreimage is the R-value preimage required to fully settle an
	// HTLC.
	PaymentPreimage [32]byte

	// ExtraData is the set of data that was appended to this message to
	// fill out the full maximum transport message size. These fields can
	// be used to specify optional data such as custom TLV fields.
	ExtraData ExtraOpaqueData
}

UpdateFulfillHTLC is sent by Alice to Bob when she wishes to settle a particular HTLC referenced by its HTLCKey within a specific active channel referenced by ChannelPoint. A subsequent CommitSig message will be sent by Alice to "lock-in" the removal of the specified HTLC, possible containing a batch signature covering several settled HTLC's.

func NewUpdateFulfillHTLC

func NewUpdateFulfillHTLC(chanID ChannelID, id uint64,
	preimage [32]byte) *UpdateFulfillHTLC

NewUpdateFulfillHTLC returns a new empty UpdateFulfillHTLC.

func (*UpdateFulfillHTLC) Decode

func (c *UpdateFulfillHTLC) Decode(r io.Reader, pver uint32) error

Decode deserializes a serialized UpdateFulfillHTLC message stored in the passed io.Reader observing the specified protocol version.

This is part of the lnwire.Message interface.

func (*UpdateFulfillHTLC) Encode

func (c *UpdateFulfillHTLC) Encode(w io.Writer, pver uint32) error

Encode serializes the target UpdateFulfillHTLC into the passed io.Writer observing the protocol version specified.

This is part of the lnwire.Message interface.

func (*UpdateFulfillHTLC) MsgType

func (c *UpdateFulfillHTLC) MsgType() MessageType

MsgType returns the integer uniquely identifying this message type on the wire.

This is part of the lnwire.Message interface.

func (*UpdateFulfillHTLC) TargetChanID

func (c *UpdateFulfillHTLC) TargetChanID() ChannelID

TargetChanID returns the channel id of the link for which this message is intended.

NOTE: Part of peer.LinkUpdater interface.

Jump to

Keyboard shortcuts

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