discovery/gossiper: use netann pkg for signing channel updates

This commit is contained in:
Conner Fromknecht
2020-03-19 13:43:39 -07:00
parent 5147a6d63d
commit 5c2fc4a2d6
2 changed files with 21 additions and 34 deletions

View File

@@ -111,12 +111,12 @@ func ExtractChannelUpdate(ownerPubKey []byte,
info.ChannelPoint)
}
// ChannelUpdateFromEdge reconstructs a signed ChannelUpdate from the given edge
// info and policy.
func ChannelUpdateFromEdge(info *channeldb.ChannelEdgeInfo,
policy *channeldb.ChannelEdgePolicy) (*lnwire.ChannelUpdate, error) {
// UnsignedChannelUpdateFromEdge reconstructs an unsigned ChannelUpdate from the
// given edge info and policy.
func UnsignedChannelUpdateFromEdge(info *channeldb.ChannelEdgeInfo,
policy *channeldb.ChannelEdgePolicy) *lnwire.ChannelUpdate {
update := &lnwire.ChannelUpdate{
return &lnwire.ChannelUpdate{
ChainHash: info.ChainHash,
ShortChannelID: lnwire.NewShortChanIDFromInt(policy.ChannelID),
Timestamp: uint32(policy.LastUpdate.Unix()),
@@ -129,6 +129,14 @@ func ChannelUpdateFromEdge(info *channeldb.ChannelEdgeInfo,
FeeRate: uint32(policy.FeeProportionalMillionths),
ExtraOpaqueData: policy.ExtraOpaqueData,
}
}
// ChannelUpdateFromEdge reconstructs a signed ChannelUpdate from the given edge
// info and policy.
func ChannelUpdateFromEdge(info *channeldb.ChannelEdgeInfo,
policy *channeldb.ChannelEdgePolicy) (*lnwire.ChannelUpdate, error) {
update := UnsignedChannelUpdateFromEdge(info, policy)
var err error
update.Signature, err = lnwire.NewSigFromRawSignature(policy.SigBytes)