lnwire

package
v0.0.0-...-e495a10 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: MIT Imports: 23 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/mraksoll4/lnd/lnwire

Documentation

Index

Constants

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
	CodeUnknownPaymentHash                     = FlagPerm | 15
	CodeIncorrectPaymentAmount                 = FlagPerm | 16
	CodeFinalExpiryTooSoon            FailCode = 17
	CodeFinalIncorrectCltvExpiry      FailCode = 18
	CodeFinalIncorrectHtlcAmount      FailCode = 19
	CodeExpiryTooFar                  FailCode = 21
)

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

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 MaxSliceLength = 65535

MaxSliceLength is the maximum allowed length for any opaque byte slices in the wire protocol.

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 GlobalFeatures map[FeatureBit]string

GlobalFeatures is a mapping of known global feature bits to a descriptive name. All known global feature bits must be assigned a name in this mapping. Global features are those which are advertised to the entire network. A full description of these feature bits is provided in the BOLT-09 specification.

View Source
var LocalFeatures = map[FeatureBit]string{
	DataLossProtectRequired: "data-loss-protect",
	DataLossProtectOptional: "data-loss-protect",
	InitialRoutingSync:      "initial-routing-sync",
	GossipQueriesRequired:   "gossip-queries",
	GossipQueriesOptional:   "gossip-queries",
}

LocalFeatures is a mapping of known connection-local feature bits to a descriptive name. All known local feature bits must be assigned a name in this mapping. Local features are those which are only sent to the peer and not advertised to the entire network. A full description of these feature bits is provided in the BOLT-09 specification.

Functions

func EncodeFailure

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

EncodeFailure encodes, including the necessary onion failure header information.

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 UpdateNodeAnnAddrs

func UpdateNodeAnnAddrs(addrs []net.Addr) func(*NodeAnnouncement)

UpdateNodeAnnAddrs is a functional option that allows updating the addresses of the given node announcement.

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 btcutil.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 btcutil.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
}

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) MaxPayloadLength

func (a *AcceptChannel) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload length for a AcceptChannel message.

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 []byte
}

AnnounceSignatures this 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) MaxPayloadLength

func (a *AnnounceSignatures) MaxPayloadLength(pver uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for this message observing the specified protocol version.

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) 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 []byte
}

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) MaxPayloadLength

func (a *ChannelAnnouncement) MaxPayloadLength(pver uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for this message observing the specified protocol version.

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
	// 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
}

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 if 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) MaxPayloadLength

func (a *ChannelReestablish) MaxPayloadLength(pver uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for this message observing the specified protocol version.

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

	// 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 []byte
}

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) MaxPayloadLength

func (a *ChannelUpdate) MaxPayloadLength(pver uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for this message observing the specified protocol version.

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 btcutil.Amount

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

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 btcutil.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) MaxPayloadLength

func (c *ClosingSigned) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for a ClosingSigned complete message observing the specified protocol version.

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
}

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) MaxPayloadLength

func (c *CommitSig) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for a CommitSig complete message observing the specified protocol version.

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.

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.

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

TODO(roasbeef): remove the error code

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) MaxPayloadLength

func (c *Error) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for an Error complete message observing the specified protocol version.

This is part of the lnwire.Message 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 ErrorCode

type ErrorCode uint8

ErrorCode represents the short error code for each of the defined errors within the Lightning Network protocol spec.

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

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

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

func (ErrorCode) Error

func (e ErrorCode) Error() string

Error returns the human redable version of the target ErrorCode.

Satisfies the Error interface.

func (ErrorCode) String

func (e ErrorCode) String() string

String returns a human readable version of the target ErrorCode.

func (ErrorCode) ToGrpcCode

func (e ErrorCode) ToGrpcCode() codes.Code

ToGrpcCode is used to generate gRPC specific code which will be propagated to the ln rpc client. This code is used to have more detailed view of what goes wrong and also in order to have the ability pragmatically determine the error and take specific actions on the client side.

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 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 cancelled. 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 anode 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

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 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 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 FailUnknownPaymentHash

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

FailUnknownPaymentHash 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 NewFailUnknownPaymentHash

func NewFailUnknownPaymentHash(amt MilliSatoshi) *FailUnknownPaymentHash

NewFailUnknownPaymentHash makes a new instance of the FailUnknownPaymentHash error bound to the specified HTLC amount.

func (FailUnknownPaymentHash) Amount

Amount is the value of the extended HTLC.

func (FailUnknownPaymentHash) Code

Code returns the failure unique code.

NOTE: Part of the FailureMessage interface.

func (*FailUnknownPaymentHash) Decode

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

Decode decodes the failure from bytes stream.

NOTE: Part of the Serializable interface.

func (*FailUnknownPaymentHash) Encode

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

Encode writes the failure in bytes stream.

NOTE: Part of the Serializable interface.

func (FailUnknownPaymentHash) Error

func (f FailUnknownPaymentHash) 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.

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

	// 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
)

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 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) 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 much.

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
}

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) MaxPayloadLength

func (f *FundingCreated) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload length for a FundingCreated message.

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 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
}

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) MaxPayloadLength

func (c *FundingLocked) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload length for a FundingLocked message. This is calculated by summing the max length of all the fields within a FundingLocked message.

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
}

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) MaxPayloadLength

func (f *FundingSigned) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload length for a FundingSigned message.

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
}

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) MaxPayloadLength

func (g *GossipTimestampRange) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for a GossipTimestampRange complete message observing the specified protocol version.

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 feature vector which affects HTLCs and thus are
	// also advertised to other nodes.
	GlobalFeatures *RawFeatureVector

	// LocalFeatures is feature vector which only affect the protocol
	// between two nodes.
	LocalFeatures *RawFeatureVector
}

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, lf *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) MaxPayloadLength

func (msg *Init) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for an Init complete message observing the specified protocol version.

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 Message

type Message interface {
	Serializable
	MsgType() MessageType
	MaxPayloadLength(uint32) uint32
}

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 btcutil.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() btcutil.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 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 []byte
}

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) MaxPayloadLength

func (a *NodeAnnouncement) MaxPayloadLength(pver uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for this message observing the specified protocol version.

This is part of the lnwire.Message interface.

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 btcutil.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 btcutil.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 btcutil.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
}

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) MaxPayloadLength

func (o *OpenChannel) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload length for a OpenChannel message.

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) MaxPayloadLength

func (p Ping) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for a Ping complete message observing the specified protocol version.

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) MaxPayloadLength

func (p *Pong) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for a Pong complete message observing the specified protocol version.

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
}

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) MaxPayloadLength

func (q *QueryChannelRange) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for a QueryChannelRange complete message observing the specified protocol version.

This is part of the lnwire.Message interface.

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 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
}

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) MaxPayloadLength

func (q *QueryShortChanIDs) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for a QueryShortChanIDs complete message observing the specified protocol version.

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) Decode

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

Decode reads the feature vector from its 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) 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) IsSet

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

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

func (*RawFeatureVector) SerializeSize

func (fv *RawFeatureVector) SerializeSize() int

SerializeSize returns the number of bytes needed to represent feature vector in byte 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 {
	// QueryChannelRange is the corresponding query to this response.
	QueryChannelRange

	// 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
}

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) MaxPayloadLength

func (c *ReplyChannelRange) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for a ReplyChannelRange complete message observing the specified protocol version.

This is part of the lnwire.Message interface.

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
}

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 now 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) MaxPayloadLength

func (c *ReplyShortChanIDsEnd) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for a ReplyShortChanIDsEnd complete message observing the specified protocol version.

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 without revocation base point will be used to
	// create the proper revocation key used within the commitment
	// transaction.
	NextRevocationKey *btcec.PublicKey
}

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) MaxPayloadLength

func (c *RevokeAndAck) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for a RevokeAndAck complete message observing the specified protocol version.

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.

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
}

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) MaxPayloadLength

func (s *Shutdown) MaxPayloadLength(pver uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for this message observing the specified protocol version.

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 *btcec.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
}

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) MaxPayloadLength

func (c *UpdateAddHTLC) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for an UpdateAddHTLC complete message observing the specified protocol version.

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.

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
}

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) MaxPayloadLength

func (c *UpdateFailHTLC) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for an UpdateFailHTLC complete message observing the specified protocol version.

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.

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
}

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) MaxPayloadLength

func (c *UpdateFailMalformedHTLC) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for a UpdateFailMalformedHTLC complete message observing the specified protocol version.

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.

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
}

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) MaxPayloadLength

func (c *UpdateFee) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for an UpdateFee complete message observing the specified protocol version.

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.

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
}

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) MaxPayloadLength

func (c *UpdateFulfillHTLC) MaxPayloadLength(uint32) uint32

MaxPayloadLength returns the maximum allowed payload size for an UpdateFulfillHTLC complete message observing the specified protocol version.

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.

Jump to

Keyboard shortcuts

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