diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index aae7e5a7e..e644fea19 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -82,7 +82,6 @@ func createLightningNode(priv *btcec.PrivateKey) *models.LightningNode { Alias: "kek" + hex.EncodeToString(pub), Features: testFeatures, Addresses: testAddrs, - ExtraOpaqueData: make([]byte, 0), } copy(n.PubKeyBytes[:], priv.PubKey().SerializeCompressed()) diff --git a/graph/db/kv_store.go b/graph/db/kv_store.go index 187fc13af..b08c86022 100644 --- a/graph/db/kv_store.go +++ b/graph/db/kv_store.go @@ -4122,7 +4122,7 @@ func deserializeLightningNode(r io.Reader) (models.LightningNode, error) { // 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( + extraBytes, err := wire.ReadVarBytes( r, 0, MaxAllowedExtraOpaqueBytes, "blob", ) switch { @@ -4132,6 +4132,10 @@ func deserializeLightningNode(r io.Reader) (models.LightningNode, error) { return models.LightningNode{}, err } + if len(extraBytes) > 0 { + node.ExtraOpaqueData = extraBytes + } + return node, nil } diff --git a/graph/db/sql_store.go b/graph/db/sql_store.go index 66a59af80..1ca00442a 100644 --- a/graph/db/sql_store.go +++ b/graph/db/sql_store.go @@ -494,10 +494,9 @@ func buildNode(ctx context.Context, db SQLQueries, dbNode *sqlc.Node) ( copy(pub[:], dbNode.PubKey) node := &models.LightningNode{ - PubKeyBytes: pub, - Features: lnwire.EmptyFeatureVector(), - LastUpdate: time.Unix(0, 0), - ExtraOpaqueData: make([]byte, 0), + PubKeyBytes: pub, + Features: lnwire.EmptyFeatureVector(), + LastUpdate: time.Unix(0, 0), } if len(dbNode.Signature) == 0 {