Documentation
¶
Index ¶
- Variables
- type CachedEdgeInfo
- type CachedEdgePolicy
- type ChannelAuthProof
- type ChannelEdgeInfo
- func (c *ChannelEdgeInfo) FundingPKScript() ([]byte, error)
- func (c *ChannelEdgeInfo) NodeKey1() (*btcec.PublicKey, error)
- func (c *ChannelEdgeInfo) NodeKey2() (*btcec.PublicKey, error)
- func (c *ChannelEdgeInfo) OtherNodeKeyBytes(thisNodeKey []byte) (route.Vertex, error)
- func (c *ChannelEdgeInfo) ToChannelAnnouncement() (*lnwire.ChannelAnnouncement1, error)
- type ChannelEdgePolicy
- type ChannelV1Fields
- type ChannelV2Fields
- type CircuitKey
- type EdgeModifier
- func WithCapacity(c btcutil.Amount) EdgeModifier
- func WithChanProof(proof *ChannelAuthProof) EdgeModifier
- func WithChannelPoint(cp wire.OutPoint) EdgeModifier
- func WithFeatures(f *lnwire.RawFeatureVector) EdgeModifier
- func WithFundingScript(script []byte) EdgeModifier
- func WithMerkleRootHash(hash chainhash.Hash) EdgeModifier
- type ForwardingPolicy
- type InboundFee
- type Node
- type NodeV1Fields
- type NodeV2Fields
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidCircuitKeyLen signals that a circuit key could not be // decoded because the byte slice is of an invalid length. ErrInvalidCircuitKeyLen = fmt.Errorf("length of serialized circuit " + "key must be 16 bytes") )
Functions ¶
This section is empty.
Types ¶
type CachedEdgeInfo ¶
type CachedEdgeInfo struct {
// ChannelID is the unique channel ID for the channel. The first 3
// bytes are the block height, the next 3 the index within the block,
// and the last 2 bytes are the output index for the channel.
ChannelID uint64
// NodeKey1Bytes is the raw public key of the first node.
NodeKey1Bytes [33]byte
// NodeKey2Bytes is the raw public key of the second node.
NodeKey2Bytes [33]byte
// Capacity is the total capacity of the channel, this is determined by
// the value output in the outpoint that created this channel.
Capacity btcutil.Amount
}
CachedEdgeInfo is a struct that only caches the information of a ChannelEdgeInfo that we actually use for pathfinding and therefore need to store in the cache.
func NewCachedEdge ¶
func NewCachedEdge(edgeInfo *ChannelEdgeInfo) *CachedEdgeInfo
NewCachedEdge creates a new CachedEdgeInfo from the provided ChannelEdgeInfo.
type CachedEdgePolicy ¶
type CachedEdgePolicy struct {
// ChannelID is the unique channel ID for the channel. The first 3
// bytes are the block height, the next 3 the index within the block,
// and the last 2 bytes are the output index for the channel.
ChannelID uint64
// HasMaxHTLC indicates whether the policy has a max HTLC value.
HasMaxHTLC bool
// IsNode1 indicates whether this policy was announced by the channel's
// node_1.
IsNode1 bool
// IsDisabled indicates whether the policy disables forwarding.
IsDisabled bool
// TimeLockDelta is the number of blocks this node will subtract from
// the expiry of an incoming HTLC. This value expresses the time buffer
// the node would like to HTLC exchanges.
TimeLockDelta uint16
// MinHTLC is the smallest value HTLC this node will forward, expressed
// in millisatoshi.
MinHTLC lnwire.MilliSatoshi
// MaxHTLC is the largest value HTLC this node will forward, expressed
// in millisatoshi.
MaxHTLC lnwire.MilliSatoshi
// FeeBaseMSat is the base HTLC fee that will be charged for forwarding
// ANY HTLC, expressed in mSAT's.
FeeBaseMSat lnwire.MilliSatoshi
// FeeProportionalMillionths is the rate that the node will charge for
// HTLCs for each millionth of a satoshi forwarded.
FeeProportionalMillionths lnwire.MilliSatoshi
// InboundFee is the fee that the node will charge for incoming HTLCs.
InboundFee fn.Option[lnwire.Fee]
// ToNodePubKey is a function that returns the to node of a policy.
// Since we only ever store the inbound policy, this is always the node
// that we query the channels for in ForEachChannel(). Therefore, we can
// save a lot of space by not storing this information in the memory and
// instead just set this function when we copy the policy from cache in
// ForEachChannel().
ToNodePubKey func() route.Vertex
// ToNodeFeatures are the to node's features. They are never set while
// the edge is in the cache, only on the copy that is returned in
// ForEachChannel().
ToNodeFeatures *lnwire.FeatureVector
}
CachedEdgePolicy is a struct that only caches the information of a ChannelEdgePolicy that we actually use for pathfinding and therefore need to store in the cache.
func NewCachedPolicy ¶
func NewCachedPolicy(policy *ChannelEdgePolicy) *CachedEdgePolicy
NewCachedPolicy turns a full policy into a minimal one that can be cached.
func (*CachedEdgePolicy) ComputeFee ¶
func (c *CachedEdgePolicy) ComputeFee( amt lnwire.MilliSatoshi) lnwire.MilliSatoshi
ComputeFee computes the fee to forward an HTLC of `amt` milli-satoshis over the passed active payment channel. This value is currently computed as specified in BOLT07, but will likely change in the near future.
type ChannelAuthProof ¶
type ChannelAuthProof struct {
// Version is the version of the channel announcement.
Version lnwire.GossipVersion
// NodeSig1Bytes are the raw bytes of the first node signature encoded
// in DER format.
//
// NOTE: v1 channel announcements only.
NodeSig1Bytes fn.Option[[]byte]
// NodeSig2Bytes are the raw bytes of the second node signature
// encoded in DER format.
//
// NOTE: v1 channel announcements only.
NodeSig2Bytes fn.Option[[]byte]
// BitcoinSig1Bytes are the raw bytes of the first bitcoin signature
// encoded in DER format.
//
// NOTE: v1 channel announcements only.
BitcoinSig1Bytes fn.Option[[]byte]
// BitcoinSig2Bytes are the raw bytes of the second bitcoin signature
// encoded in DER format.
//
// NOTE: v1 channel announcements only.
BitcoinSig2Bytes fn.Option[[]byte]
// Signature is the raw bytes of the single schnorr signature for v2
// channel announcements.
//
// NOTE: v2 channel announcements only.
Signature fn.Option[[]byte]
}
ChannelAuthProof is the authentication proof (the signature portion) for a channel.
For v1 channels: Using the four node and bitcoin signatures contained in the struct, and some auxiliary knowledge (the funding script, node identities, and outpoint) nodes on the network are able to validate the authenticity and existence of a channel. Each of these signatures signs the following digest: chanID || nodeID1 || nodeID2 || bitcoinKey1|| bitcoinKey2 || 2-byte-feature-len || features.
For v2 channels: The single schnorr signature signs the tlv fields of the v2 channel announcement message which are in the signed range.
func NewV1ChannelAuthProof ¶
func NewV1ChannelAuthProof(nodeSig1, nodeSig2, bitcoinSig1, bitcoinSig2 []byte) *ChannelAuthProof
NewV1ChannelAuthProof creates a new ChannelAuthProof for a v1 channel announcement.
func NewV2ChannelAuthProof ¶
func NewV2ChannelAuthProof(signature []byte) *ChannelAuthProof
NewV2ChannelAuthProof creates a new ChannelAuthProof for a v2 channel announcement.
func (*ChannelAuthProof) BitcoinSig1 ¶
func (c *ChannelAuthProof) BitcoinSig1() []byte
BitcoinSig1 returns the first bitcoin signature bytes, or nil if not present.
func (*ChannelAuthProof) BitcoinSig2 ¶
func (c *ChannelAuthProof) BitcoinSig2() []byte
BitcoinSig2 returns the second bitcoin signature bytes, or nil if not present.
func (*ChannelAuthProof) IsEmpty ¶
func (c *ChannelAuthProof) IsEmpty() bool
IsEmpty check is the authentication proof is empty Proof is empty.
func (*ChannelAuthProof) NodeSig1 ¶
func (c *ChannelAuthProof) NodeSig1() []byte
NodeSig1 returns the first node signature bytes, or nil if not present.
func (*ChannelAuthProof) NodeSig2 ¶
func (c *ChannelAuthProof) NodeSig2() []byte
NodeSig2 returns the second node signature bytes, or nil if not present.
func (*ChannelAuthProof) Sig ¶
func (c *ChannelAuthProof) Sig() []byte
Sig returns the v2 signature bytes, or nil if not present.
type ChannelEdgeInfo ¶
type ChannelEdgeInfo struct {
// Version is the gossip version that this channel was advertised on.
Version lnwire.GossipVersion
// ChannelID is the unique channel ID for the channel. The first 3
// bytes are the block height, the next 3 the index within the block,
// and the last 2 bytes are the output index for the channel.
ChannelID uint64
// ChainHash is the hash that uniquely identifies the chain that this
// channel was opened within.
ChainHash chainhash.Hash
// NodeKey1Bytes is the raw public key of the first node.
NodeKey1Bytes route.Vertex
// NodeKey2Bytes is the raw public key of the second node.
NodeKey2Bytes route.Vertex
// BitcoinKey1Bytes is the raw public key of the first node.
//
// NOTE: this must be set for v1 channels but is optional for v2 and
// beyond.
BitcoinKey1Bytes fn.Option[route.Vertex]
// BitcoinKey2Bytes is the raw public key of the second node.
//
// NOTE: this must be set for v1 channels but is optional for v2 and
// beyond.
BitcoinKey2Bytes fn.Option[route.Vertex]
// Features is the list of protocol features supported by this channel
// edge.
Features *lnwire.FeatureVector
// AuthProof is the authentication proof for this channel. This proof
// contains a set of signatures binding four identities, which attests
// to the legitimacy of the advertised channel.
AuthProof *ChannelAuthProof
// ChannelPoint is the funding outpoint of the channel. This can be
// used to uniquely identify the channel within the channel graph.
ChannelPoint wire.OutPoint
// Capacity is the total capacity of the channel, this is determined by
// the value output in the outpoint that created this channel.
Capacity btcutil.Amount
// FundingScript holds the script of the channel's funding transaction.
//
// NOTE: this is not currently persisted and so will not be present if
// the edge object is loaded from the database.
FundingScript fn.Option[[]byte]
// MerkleRootHash is an optional root hash of a Merkle tree that the
// funding output is committed to. This is then used to compute the
// final funding output script.
//
// NOTE: only used for version 2 channels and beyond.
MerkleRootHash fn.Option[chainhash.Hash]
// 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.
//
// NOTE: only used for version 1 channels.
ExtraOpaqueData []byte
// ExtraSignedFields is a map of extra fields that are covered by the
// node announcement's signature that we have not explicitly parsed.
//
// NOTE: This is only used for version 2 node announcements and beyond.
ExtraSignedFields map[uint64][]byte
}
ChannelEdgeInfo represents a fully authenticated channel along with all its unique attributes. Once an authenticated channel announcement has been processed on the network, then an instance of ChannelEdgeInfo encapsulating the channels attributes is stored. The other portions relevant to routing policy of a channel are stored within a ChannelEdgePolicy for each direction of the channel.
func NewV1Channel ¶
func NewV1Channel(chanID uint64, chainHash chainhash.Hash, node1, node2 route.Vertex, v1Fields *ChannelV1Fields, opts ...EdgeModifier) (*ChannelEdgeInfo, error)
NewV1Channel creates a new ChannelEdgeInfo for a v1 channel announcement. It takes the required fields for all channels (chanID, chainHash, node keys) and v1-specific fields, along with optional modifiers for setting additional fields like capacity, channel point, features, and auth proof.
The constructor validates that if an AuthProof is provided via modifiers, its version matches the channel version (v1).
func NewV2Channel ¶
func NewV2Channel(chanID uint64, chainHash chainhash.Hash, node1, node2 route.Vertex, v2Fields *ChannelV2Fields, opts ...EdgeModifier) (*ChannelEdgeInfo, error)
NewV2Channel creates a new ChannelEdgeInfo for a v2 channel announcement.
func (*ChannelEdgeInfo) FundingPKScript ¶
func (c *ChannelEdgeInfo) FundingPKScript() ([]byte, error)
FundingPKScript returns the funding output's pkScript for the channel.
func (*ChannelEdgeInfo) NodeKey1 ¶
func (c *ChannelEdgeInfo) NodeKey1() (*btcec.PublicKey, error)
NodeKey1 is the identity public key of the "first" node that was involved in the creation of this channel. A node is considered "first" if the lexicographical ordering the its serialized public key is "smaller" than that of the other node involved in channel creation.
func (*ChannelEdgeInfo) NodeKey2 ¶
func (c *ChannelEdgeInfo) NodeKey2() (*btcec.PublicKey, error)
NodeKey2 is the identity public key of the "second" node that was involved in the creation of this channel. A node is considered "second" if the lexicographical ordering the its serialized public key is "larger" than that of the other node involved in channel creation.
func (*ChannelEdgeInfo) OtherNodeKeyBytes ¶
func (c *ChannelEdgeInfo) OtherNodeKeyBytes(thisNodeKey []byte) ( route.Vertex, error)
OtherNodeKeyBytes returns the node key bytes of the other end of the channel.
func (*ChannelEdgeInfo) ToChannelAnnouncement ¶
func (c *ChannelEdgeInfo) ToChannelAnnouncement() ( *lnwire.ChannelAnnouncement1, error)
ToChannelAnnouncement converts the ChannelEdgeInfo to a lnwire.ChannelAnnouncement1 message. Returns an error if AuthProof is nil or if the version is not v1.
type ChannelEdgePolicy ¶
type ChannelEdgePolicy struct {
// Version is the gossip version of the channel update that produced
// this policy.
Version lnwire.GossipVersion
// SigBytes is the raw bytes of the signature of the channel edge
// policy. We'll only parse these if the caller needs to access the
// signature for validation purposes.
SigBytes []byte
// ChannelID is the unique channel ID for the channel. The first 3
// bytes are the block height, the next 3 the index within the block,
// and the last 2 bytes are the output index for the channel.
ChannelID uint64
// LastUpdate is the last time an authenticated edge for this channel
// was received.
LastUpdate time.Time
// LastBlockHeight is the block height that timestamps the last update
// for v2 channel updates.
LastBlockHeight uint32
// SecondPeer indicates whether this policy was announced by the second
// peer in the channel for v2 channel updates.
SecondPeer bool
// MessageFlags is a bitfield which indicates the presence of optional
// fields (like max_htlc) in the policy.
MessageFlags lnwire.ChanUpdateMsgFlags
// ChannelFlags is a bitfield which signals the capabilities of the
// channel as well as the directed edge this update applies to.
ChannelFlags lnwire.ChanUpdateChanFlags
// DisableFlags is a v2-specific bitfield which signals whether the
// channel is disabled for incoming or outgoing traffic.
DisableFlags lnwire.ChanUpdateDisableFlags
// TimeLockDelta is the number of blocks this node will subtract from
// the expiry of an incoming HTLC. This value expresses the time buffer
// the node would like to HTLC exchanges.
TimeLockDelta uint16
// MinHTLC is the smallest value HTLC this node will forward, expressed
// in millisatoshi.
MinHTLC lnwire.MilliSatoshi
// MaxHTLC is the largest value HTLC this node will forward, expressed
// in millisatoshi.
MaxHTLC lnwire.MilliSatoshi
// FeeBaseMSat is the base HTLC fee that will be charged for forwarding
// ANY HTLC, expressed in mSAT's.
FeeBaseMSat lnwire.MilliSatoshi
// FeeProportionalMillionths is the rate that the node will charge for
// HTLCs for each millionth of a satoshi forwarded.
FeeProportionalMillionths lnwire.MilliSatoshi
// ToNode is the public key of the node that this directed edge leads
// to. Using this pub key, the channel graph can further be traversed.
ToNode [33]byte
// InboundFee is the fee that must be paid for incoming HTLCs.
//
// NOTE: for our kvdb implementation of the graph store, inbound fees
// are still only persisted as part of extra opaque data and so this
// field is not explicitly stored but is rather populated from the
// ExtraOpaqueData field on deserialization. For our SQL implementation,
// this field will be explicitly persisted in the database.
InboundFee fn.Option[lnwire.Fee]
// 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 lnwire.ExtraOpaqueData
// ExtraSignedFields are the extra signed fields found in v2 channel
// updates.
ExtraSignedFields map[uint64][]byte
}
ChannelEdgePolicy represents a *directed* edge within the channel graph. For each channel in the database, there are two distinct edges: one for each possible direction of travel along the channel. The edges themselves hold information concerning fees, and minimum time-lock information which is utilized during path finding.
func ChanEdgePolicyFromWire ¶
func ChanEdgePolicyFromWire(scid uint64, update lnwire.ChannelUpdate) (*ChannelEdgePolicy, error)
ChanEdgePolicyFromWire constructs a ChannelEdgePolicy from a channel update message.
func (*ChannelEdgePolicy) ComputeFee ¶
func (c *ChannelEdgePolicy) ComputeFee( amt lnwire.MilliSatoshi) lnwire.MilliSatoshi
ComputeFee computes the fee to forward an HTLC of `amt` milli-satoshis over the passed active payment channel. This value is currently computed as specified in BOLT07, but will likely change in the near future.
func (*ChannelEdgePolicy) IsDisabled ¶
func (c *ChannelEdgePolicy) IsDisabled() bool
IsDisabled determines whether the edge has the disabled bit set.
NOTE: for v2 channel updates, we return true here only if both the incoming and outgoing disabled bits are set.
func (*ChannelEdgePolicy) IsNode1 ¶
func (c *ChannelEdgePolicy) IsNode1() bool
IsNode1 returns true if this policy was announced by the channel's node_1.
func (*ChannelEdgePolicy) String ¶
func (c *ChannelEdgePolicy) String() string
String returns a human-readable version of the channel edge policy.
type ChannelV1Fields ¶
type ChannelV1Fields struct {
// BitcoinKey1Bytes is the raw public key of the first node.
BitcoinKey1Bytes route.Vertex
// BitcoinKey2Bytes is the raw public key of the second node.
BitcoinKey2Bytes route.Vertex
// 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
}
ChannelV1Fields contains the fields that are specific to v1 channel announcements.
type ChannelV2Fields ¶
type ChannelV2Fields struct {
// BitcoinKey1Bytes is the raw public key of the first node.
BitcoinKey1Bytes fn.Option[route.Vertex]
// BitcoinKey2Bytes is the raw public key of the second node.
BitcoinKey2Bytes fn.Option[route.Vertex]
// FundingScript is the funding output's pkScript. This is required for
// v2 channels when the bitcoin keys are not provided.
FundingScript fn.Option[[]byte]
// MerkleRootHash is an optional root hash of a Merkle tree that the
// funding output is committed to.
MerkleRootHash fn.Option[chainhash.Hash]
// ExtraSignedFields is a map of extra fields that are covered by the
// node announcement's signature that we have not explicitly parsed.
//
// NOTE: This is only used for version 2 node announcements and beyond.
ExtraSignedFields map[uint64][]byte
}
ChannelV2Fields contains the fields that are specific to v2 channel announcements.
type CircuitKey ¶
type CircuitKey struct {
// ChanID is the short chanid indicating the HTLC's origin.
//
// NOTE: It is fine for this value to be blank, as this indicates a
// locally-sourced payment.
ChanID lnwire.ShortChannelID
// HtlcID is the unique htlc index predominately assigned by links,
// though can also be assigned by switch in the case of locally-sourced
// payments.
HtlcID uint64
}
CircuitKey is used by a channel to uniquely identify the HTLCs it receives from the switch, and is used to purge our in-memory state of HTLCs that have already been processed by a link. Two list of CircuitKeys are included in each CommitDiff to allow a link to determine which in-memory htlcs directed the opening and closing of circuits in the switch's circuit map.
func (CircuitKey) Bytes ¶
func (k CircuitKey) Bytes() []byte
Bytes returns the serialized bytes for this circuit key.
func (*CircuitKey) Decode ¶
func (k *CircuitKey) Decode(r io.Reader) error
Decode reads a CircuitKey from the provided io.Reader.
func (*CircuitKey) Encode ¶
func (k *CircuitKey) Encode(w io.Writer) error
Encode writes a CircuitKey to the provided io.Writer.
func (*CircuitKey) SetBytes ¶
func (k *CircuitKey) SetBytes(bs []byte) error
SetBytes deserializes the given bytes into this CircuitKey.
func (CircuitKey) String ¶
func (k CircuitKey) String() string
String returns a string representation of the CircuitKey.
type EdgeModifier ¶
type EdgeModifier func(*ChannelEdgeInfo)
EdgeModifier is a functional option that modifies a ChannelEdgeInfo.
func WithCapacity ¶
func WithCapacity(c btcutil.Amount) EdgeModifier
WithCapacity sets the capacity on the edge.
func WithChanProof ¶
func WithChanProof(proof *ChannelAuthProof) EdgeModifier
WithChanProof sets the authentication proof on the edge.
func WithChannelPoint ¶
func WithChannelPoint(cp wire.OutPoint) EdgeModifier
WithChannelPoint sets the channel point (funding outpoint) on the edge.
func WithFeatures ¶
func WithFeatures(f *lnwire.RawFeatureVector) EdgeModifier
WithFeatures sets the feature vector on the edge.
func WithFundingScript ¶
func WithFundingScript(script []byte) EdgeModifier
WithFundingScript sets the funding script on the edge.
func WithMerkleRootHash ¶
func WithMerkleRootHash(hash chainhash.Hash) EdgeModifier
WithMerkleRootHash sets the merkle root hash on the edge.
type ForwardingPolicy ¶
type ForwardingPolicy struct {
// MinHTLCOut is the smallest HTLC that is to be forwarded.
MinHTLCOut lnwire.MilliSatoshi
// MaxHTLC is the largest HTLC that is to be forwarded.
MaxHTLC lnwire.MilliSatoshi
// BaseFee is the base fee, expressed in milli-satoshi that must be
// paid for each incoming HTLC. This field, combined with FeeRate is
// used to compute the required fee for a given HTLC.
BaseFee lnwire.MilliSatoshi
// FeeRate is the fee rate, expressed in milli-satoshi that must be
// paid for each incoming HTLC. This field combined with BaseFee is
// used to compute the required fee for a given HTLC.
FeeRate lnwire.MilliSatoshi
// InboundFee is the fee that must be paid for incoming HTLCs.
InboundFee InboundFee
// TimeLockDelta is the absolute time-lock value, expressed in blocks,
// that will be subtracted from an incoming HTLC's timelock value to
// create the time-lock value for the forwarded outgoing HTLC. The
// following constraint MUST hold for an HTLC to be forwarded:
//
// * incomingHtlc.timeLock - timeLockDelta = fwdInfo.OutgoingCTLV
//
// where fwdInfo is the forwarding information extracted from the
// per-hop payload of the incoming HTLC's onion packet.
TimeLockDelta uint32
}
ForwardingPolicy describes the set of constraints that a given ChannelLink is to adhere to when forwarding HTLC's. For each incoming HTLC, this set of constraints will be consulted in order to ensure that adequate fees are paid, and our time-lock parameters are respected. In the event that an incoming HTLC violates any of these constraints, it is to be _rejected_ with the error possibly carrying along a ChannelUpdate message that includes the latest policy.
type InboundFee ¶
func NewInboundFeeFromWire ¶
func NewInboundFeeFromWire(fee lnwire.Fee) InboundFee
NewInboundFeeFromWire constructs an inbound fee structure from a wire fee.
func (*InboundFee) CalcFee ¶
func (i *InboundFee) CalcFee(amt lnwire.MilliSatoshi) int64
CalcFee calculates what the inbound fee should minimally be for forwarding the given amount. This amount is the total of the outgoing amount plus the outbound fee, which is what the inbound fee is based on.
func (*InboundFee) ToWire ¶
func (i *InboundFee) ToWire() lnwire.Fee
ToWire converts the inbound fee to a wire fee structure.
type Node ¶
type Node struct {
// Version is the gossip version that this node was advertised on.
Version lnwire.GossipVersion
// PubKeyBytes is the raw bytes of the public key of the target node.
PubKeyBytes [33]byte
// LastUpdate is the last time the vertex information for this node has
// been updated.
LastUpdate time.Time
// LastBlockHeight is the block height that timestamps the last update
// we received for this node. This is only used if this is a V2 node
// announcement.
LastBlockHeight uint32
// Address is the TCP address this node is reachable over.
Addresses []net.Addr
// Color is the selected color for the node.
Color fn.Option[color.RGBA]
// Alias is a nick-name for the node. The alias can be used to confirm
// a node's identity or to serve as a short ID for an address book.
Alias fn.Option[string]
// AuthSigBytes is the raw signature under the advertised public key
// which serves to authenticate the attributes announced by this node.
AuthSigBytes []byte
// Features is the list of protocol features supported by this node.
Features *lnwire.FeatureVector
// 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. This is only used for V1 node announcements.
ExtraOpaqueData []byte
// ExtraSignedFields is a map of extra fields that are covered by the
// node announcement's signature that we have not explicitly parsed.
// This is only used for version 2 node announcements and beyond.
ExtraSignedFields map[uint64][]byte
}
Node represents an individual vertex/node within the channel graph. A node is connected to other nodes by one or more channel edges emanating from it. As the graph is directed, a node will also have an incoming edge attached to it for each outgoing edge.
func NewShellNode ¶
func NewShellNode(v lnwire.GossipVersion, pubKey route.Vertex) *Node
NewShellNode creates a new shell node with the given gossip version and public key.
func NewV1Node ¶
func NewV1Node(pub route.Vertex, n *NodeV1Fields) *Node
NewV1Node creates a new version 1 node from the passed fields.
func NewV1ShellNode ¶
NewV1ShellNode creates a new shell version 1 node.
func NewV2Node ¶
func NewV2Node(pub route.Vertex, n *NodeV2Fields) *Node
NewV2Node creates a new version 2 node from the passed fields.
func NodeFromWireAnnouncement ¶
func NodeFromWireAnnouncement(msg *lnwire.NodeAnnouncement1) *Node
NodeFromWireAnnouncement creates a Node instance from an lnwire.NodeAnnouncement1 message.
func (*Node) HaveAnnouncement ¶
HaveAnnouncement returns true if we have received a node announcement for this node. We determine this by checking if we have a signature for the announcement.
func (*Node) NodeAnnouncement ¶
func (n *Node) NodeAnnouncement(signed bool) (*lnwire.NodeAnnouncement1, error)
NodeAnnouncement retrieves the latest node announcement of the node.
type NodeV1Fields ¶
type NodeV1Fields struct {
// Address is the TCP address this node is reachable over.
Addresses []net.Addr
// AuthSigBytes is the raw signature under the advertised public key
// which serves to authenticate the attributes announced by this node.
AuthSigBytes []byte
// Features is the list of protocol features supported by this node.
Features *lnwire.RawFeatureVector
// Color is the selected color for the node.
Color color.RGBA
// Alias is a nick-name for the node. The alias can be used to confirm
// a node's identity or to serve as a short ID for an address book.
Alias string
// LastUpdate is the last time the vertex information for this node has
// been updated.
LastUpdate time.Time
// 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
}
NodeV1Fields houses the fields that are specific to a version 1 node announcement.
type NodeV2Fields ¶
type NodeV2Fields struct {
// LastBlockHeight is the block height that timestamps the last update
// we received for this node.
LastBlockHeight uint32
// Address is the TCP address this node is reachable over.
Addresses []net.Addr
// Color is the selected color for the node.
Color fn.Option[color.RGBA]
// Alias is a nick-name for the node. The alias can be used to confirm
// a node's identity or to serve as a short ID for an address book.
Alias fn.Option[string]
// Signature is the schnorr signature under the advertised public key
// which serves to authenticate the attributes announced by this node.
Signature []byte
// Features is the list of protocol features supported by this node.
Features *lnwire.RawFeatureVector
// ExtraSignedFields is a map of extra fields that are covered by the
// node announcement's signature that we have not explicitly parsed.
ExtraSignedFields map[uint64][]byte
}
NodeV2Fields houses the fields that are specific to a version 2 node announcement.