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

+5 -5
View File
@@ -256,7 +256,7 @@ func writeElement(w io.Writer, element interface{}) error {
if _, err := w.Write(idx[:]); err != nil {
return err
}
case wire.OutPoint:
case *wire.OutPoint:
// TODO(roasbeef): consolidate with above
// First write out the previous txid.
var h [32]byte
@@ -497,7 +497,7 @@ func readElement(r io.Reader, element interface{}) error {
}
(*e).PreviousOutPoint.Index = binary.BigEndian.Uint32(idxBytes[:])
return nil
case *wire.OutPoint:
case **wire.OutPoint:
// TODO(roasbeef): consolidate with above
var h [32]byte
if _, err = io.ReadFull(r, h[:]); err != nil {
@@ -507,15 +507,15 @@ func readElement(r io.Reader, element interface{}) error {
if err != nil {
return err
}
(*e).Hash = *hash
// Index
var idxBytes [4]byte
_, err = io.ReadFull(r, idxBytes[:])
if err != nil {
return err
}
(*e).Index = binary.BigEndian.Uint32(idxBytes[:])
index := binary.BigEndian.Uint32(idxBytes[:])
*e = wire.NewOutPoint(hash, index)
default:
return fmt.Errorf("Unknown type in readElement: %T", e)
}