channeldb: add storing of node signature and add edge signature

In order to properly announce the channel the announcements proofs
should be persistent in boltdb.
This commit is contained in:
Andrey Samokhvalov authored and Olaoluwa Osuntokun committed 2017-03-29 19:49:05 -07:00
1 parent 2105a06a26
commit 19174ebdfd
4 files changed
+46

No files matched your search

+34
View File
@@ -1108,6 +1108,10 @@ func (p *ChannelAuthProof) IsEmpty() bool {
// information concerning fees, and minimum time-lock information which is
// utilized during path finding.
type ChannelEdgePolicy struct {
// Signature is a channel announcement signature, which is needed for
// proper edge policy announcement.
Signature *btcec.Signature
// ChannelID is the unique channel ID for the channel. The first 3
// bytes are the block height, the next 3 the index within the block,
// and the last 2 bytes are the output index for the channel.
@@ -1361,6 +1365,11 @@ func putLightningNode(nodeBucket *bolt.Bucket, aliasBucket *bolt.Bucket, node *L
}
}
err := wire.WriteVarBytes(&b, 0, node.AuthSig.Serialize())
if err != nil {
return err
}
return nodeBucket.Put(nodePub, b.Bytes())
}
@@ -1462,6 +1471,16 @@ func deserializeLightningNode(r io.Reader) (*LightningNode, error) {
}
node.Addresses = addresses
sigBytes, err := wire.ReadVarBytes(r, 0, 80, "sig")
if err != nil {
return nil, err
}
node.AuthSig, err = btcec.ParseSignature(sigBytes, btcec.S256())
if err != nil {
return nil, err
}
return node, nil
}
@@ -1626,6 +1645,11 @@ func putChanEdgePolicy(edges *bolt.Bucket, edge *ChannelEdgePolicy, from, to []b
var b bytes.Buffer
err := wire.WriteVarBytes(&b, 0, edge.Signature.Serialize())
if err != nil {
return err
}
if err := binary.Write(&b, byteOrder, edge.ChannelID); err != nil {
return err
}
@@ -1723,6 +1747,16 @@ func deserializeChanEdgePolicy(r io.Reader,
edge := &ChannelEdgePolicy{}
sigBytes, err := wire.ReadVarBytes(r, 0, 80, "sig")
if err != nil {
return nil, err
}
edge.Signature, err = btcec.ParseSignature(sigBytes, btcec.S256())
if err != nil {
return nil, err
}
if err := binary.Read(r, byteOrder, &edge.ChannelID); err != nil {
return nil, err
}