mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 14:11:04 +02:00
refactor+multi: use *lnwire.FeatureVector for ChannelEdgeInfo features
In this commit, we move the serialisation details of a channel's features to the DB layer and change the `models` field to instead use a more useful `*lnwire.FeatureVector` type. This makes the features easier to work with and moves the serialisation to where it is actually used.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package netann
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
@@ -49,14 +48,11 @@ func CreateChanAnnouncement(chanProof *models.ChannelAuthProof,
|
||||
ChainHash: chanInfo.ChainHash,
|
||||
BitcoinKey1: chanInfo.BitcoinKey1Bytes,
|
||||
BitcoinKey2: chanInfo.BitcoinKey2Bytes,
|
||||
Features: lnwire.NewRawFeatureVector(),
|
||||
Features: chanInfo.Features.RawFeatureVector,
|
||||
ExtraOpaqueData: chanInfo.ExtraOpaqueData,
|
||||
}
|
||||
|
||||
err := chanAnn.Features.Decode(bytes.NewReader(chanInfo.Features))
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
var err error
|
||||
chanAnn.BitcoinSig1, err = lnwire.NewSigFromECDSARawSignature(
|
||||
chanProof.BitcoinSig1Bytes,
|
||||
)
|
||||
|
@@ -24,11 +24,6 @@ func TestCreateChanAnnouncement(t *testing.T) {
|
||||
key := [33]byte{0x1}
|
||||
var sig lnwire.Sig
|
||||
features := lnwire.NewRawFeatureVector(lnwire.AnchorsRequired)
|
||||
var featuresBuf bytes.Buffer
|
||||
if err := features.Encode(&featuresBuf); err != nil {
|
||||
t.Fatalf("unable to encode features: %v", err)
|
||||
}
|
||||
|
||||
expChanAnn := &lnwire.ChannelAnnouncement1{
|
||||
ChainHash: chainhash.Hash{0x1},
|
||||
ShortChannelID: lnwire.ShortChannelID{BlockHeight: 1},
|
||||
@@ -59,8 +54,10 @@ func TestCreateChanAnnouncement(t *testing.T) {
|
||||
NodeKey2Bytes: key,
|
||||
BitcoinKey1Bytes: key,
|
||||
BitcoinKey2Bytes: key,
|
||||
Features: featuresBuf.Bytes(),
|
||||
ExtraOpaqueData: expChanAnn.ExtraOpaqueData,
|
||||
Features: lnwire.NewFeatureVector(
|
||||
features, lnwire.Features,
|
||||
),
|
||||
ExtraOpaqueData: expChanAnn.ExtraOpaqueData,
|
||||
}
|
||||
chanAnn, _, _, err := CreateChanAnnouncement(
|
||||
chanProof, chanInfo, nil, nil,
|
||||
|
Reference in New Issue
Block a user