From 5ba95585e5e7fba7e6dd30f90bb8b9b6a06342b2 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Tue, 23 Oct 2018 18:28:19 -0700 Subject: [PATCH] watchtower/wtwire/init: borrow LN init msg for WT init --- watchtower/wtwire/init.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 watchtower/wtwire/init.go diff --git a/watchtower/wtwire/init.go b/watchtower/wtwire/init.go new file mode 100644 index 000000000..d9056e2be --- /dev/null +++ b/watchtower/wtwire/init.go @@ -0,0 +1,30 @@ +package wtwire + +import "github.com/lightningnetwork/lnd/lnwire" + +// Init is the first message sent over the watchtower wire protocol, and +// specifies features and level of requiredness maintained by the sending node. +// The watchtower Init message is identical to the LN Init message, except it +// uses a different message type to ensure the two are not conflated. +type Init struct { + *lnwire.Init +} + +// NewInitMessage generates a new Init message from raw global and local feature +// vectors. +func NewInitMessage(gf, lf *lnwire.RawFeatureVector) *Init { + return &Init{ + Init: lnwire.NewInitMessage(gf, lf), + } +} + +// MsgType returns the integer uniquely identifying this message type on the +// wire. +// +// This is part of the wtwire.Message interface. +func (msg *Init) MsgType() MessageType { + return MsgInit +} + +// A compile-time constraint to ensure Init implements the Message interface. +var _ Message = (*Init)(nil)