lnwire: channels are now identified by outpoint

This commit modifies most of the wire messages to uniquely identify any
*active* channels by their funding output. This allows the wire
protocol to support funding transactions which open several channels in
parallel.

Any pending channels created by partial completion of the funding
workflow are to be identified by a uint64 initialized by both sides as
follows: the initiator of the connection starts from 0, while the
listening node starts from (1 << 63). These pending channel identifiers
are expected to be monotonically increasing with each new funding
workflow between two nodes. This identifier is volatile w.r.t to each
connection initiation.
This commit is contained in:
Olaoluwa Osuntokun committed 2016-06-21 13:13:07 -07:00
1 parent 7b7d572984
commit 6c7880ef76
25 files changed
+236 -202

No files matched your search

+11 -8
View File
@@ -3,16 +3,19 @@ package lnwire
import (
"fmt"
"io"
"github.com/roasbeef/btcd/wire"
)
// ErrorGeneric represents a generic error bound to an exact channel. The
// message format is purposefully general in order to allow expressino of a wide
// array of possible errors. Each ErrorGeneric message is directed at a particular
// open channel referenced by ChannelID.
// open channel referenced by ChannelPoint.
type ErrorGeneric struct {
// ChannelID references the active channel in which the error occured
// within.
ChannelID uint64
// ChannelPoint references the active channel in which the error occured
// within. A ChannelPoint of zeroHash:0 denotes this error applies to
// the entire established connection.
ChannelPoint *wire.OutPoint
// ErrorID quickly defines the nature of the error according to error
// type.
@@ -38,10 +41,10 @@ var _ Message = (*ErrorGeneric)(nil)
//
// This is part of the lnwire.Message interface.
func (c *ErrorGeneric) Decode(r io.Reader, pver uint32) error {
// ChannelID(8)
// ChannelPoint(8)
// Problem
err := readElements(r,
&c.ChannelID,
&c.ChannelPoint,
&c.ErrorID,
&c.Problem,
)
@@ -58,7 +61,7 @@ func (c *ErrorGeneric) Decode(r io.Reader, pver uint32) error {
// This is part of the lnwire.Message interface.
func (c *ErrorGeneric) Encode(w io.Writer, pver uint32) error {
err := writeElements(w,
c.ChannelID,
c.ChannelPoint,
c.ErrorID,
c.Problem,
)
@@ -104,7 +107,7 @@ func (c *ErrorGeneric) Validate() error {
// This is part of the lnwire.Message interface.
func (c *ErrorGeneric) String() string {
return fmt.Sprintf("\n--- Begin ErrorGeneric ---\n") +
fmt.Sprintf("ChannelID:\t%d\n", c.ChannelID) +
fmt.Sprintf("ChannelPoint:\t%d\n", c.ChannelPoint) +
fmt.Sprintf("ErrorID:\t%d\n", c.ErrorID) +
fmt.Sprintf("Problem:\t%s\n", c.Problem) +
fmt.Sprintf("--- End ErrorGeneric ---\n")