diff --git a/channeldb/graph.go b/channeldb/graph.go index 1d7625ba7..340cc24df 100644 --- a/channeldb/graph.go +++ b/channeldb/graph.go @@ -1694,6 +1694,14 @@ type LightningNode struct { // 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. + ExtraOpaqueData []byte + db *DB // TODO(roasbeef): discovery will need storage to keep it's last IP @@ -1978,6 +1986,14 @@ type ChannelEdgeInfo struct { // the value output in the outpoint that created this channel. Capacity btcutil.Amount + // 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 + db *DB } @@ -2322,6 +2338,14 @@ type ChannelEdgePolicy struct { // this pointer the channel graph can further be traversed. Node *LightningNode + // 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 + db *DB } @@ -2691,6 +2715,11 @@ func putLightningNode(nodeBucket *bolt.Bucket, aliasBucket *bolt.Bucket, return err } + err = wire.WriteVarBytes(&b, 0, node.ExtraOpaqueData) + if err != nil { + return err + } + if err := aliasBucket.Put(nodePub, []byte(node.Alias)); err != nil { return err } @@ -2815,6 +2844,13 @@ func deserializeLightningNode(r io.Reader) (LightningNode, error) { return LightningNode{}, err } + // We'll try and see if there are any opaque bytes left, if not, then + // we'll ignore the EOF error and return the node as is. + node.ExtraOpaqueData, err = wire.ReadVarBytes(r, 0, 1000, "blob") + if err != nil && err != io.ErrUnexpectedEOF { + return LightningNode{}, err + } + return node, nil } @@ -2873,6 +2909,11 @@ func putChanEdgeInfo(edgeIndex *bolt.Bucket, edgeInfo *ChannelEdgeInfo, chanID [ return err } + err := wire.WriteVarBytes(&b, 0, edgeInfo.ExtraOpaqueData) + if err != nil { + return err + } + return edgeIndex.Put(chanID[:], b.Bytes()) } @@ -2950,6 +2991,13 @@ func deserializeChanEdgeInfo(r io.Reader) (ChannelEdgeInfo, error) { return ChannelEdgeInfo{}, err } + // We'll try and see if there are any opaque bytes left, if not, then + // we'll ignore the EOF error and return the edge as is. + edgeInfo.ExtraOpaqueData, err = wire.ReadVarBytes(r, 0, 1000, "blob") + if err != nil && err != io.ErrUnexpectedEOF { + return ChannelEdgeInfo{}, err + } + return edgeInfo, nil } @@ -2998,6 +3046,10 @@ func putChanEdgePolicy(edges, nodes *bolt.Bucket, edge *ChannelEdgePolicy, return err } + if err := wire.WriteVarBytes(&b, 0, edge.ExtraOpaqueData); err != nil { + return err + } + // Before we write out the new edge, we'll create a new entry in the // update index in order to keep it fresh. var indexKey [8 + 8]byte @@ -3182,6 +3234,13 @@ func deserializeChanEdgePolicy(r io.Reader, pub[:], err) } + // We'll try and see if there are any opaque bytes left, if not, then + // we'll ignore the EOF error and return the edge as is. + edge.ExtraOpaqueData, err = wire.ReadVarBytes(r, 0, 1000, "blob") + if err != nil && err != io.ErrUnexpectedEOF { + return nil, err + } + edge.Node = &node return edge, nil }