diff --git a/lnwire/lnwire.go b/lnwire/lnwire.go index b47b0d5a..705ab358 100644 --- a/lnwire/lnwire.go +++ b/lnwire/lnwire.go @@ -86,6 +86,12 @@ func writeElement(w io.Writer, element interface{}) error { if _, err := w.Write(b[:]); err != nil { return err } + case FundingFlag: + var b [1]byte + b[0] = uint8(e) + if _, err := w.Write(b[:]); err != nil { + return err + } case uint16: var b [2]byte binary.BigEndian.PutUint16(b[:], e) @@ -388,6 +394,12 @@ func readElement(r io.Reader, element interface{}) error { return err } *e = b[0] + case *FundingFlag: + var b [1]uint8 + if _, err := r.Read(b[:]); err != nil { + return err + } + *e = FundingFlag(b[0]) case *uint16: var b [2]byte if _, err := io.ReadFull(r, b[:]); err != nil { diff --git a/lnwire/lnwire_test.go b/lnwire/lnwire_test.go index 7636297d..43521dd9 100644 --- a/lnwire/lnwire_test.go +++ b/lnwire/lnwire_test.go @@ -154,7 +154,7 @@ func TestLightningWireProtocol(t *testing.T) { FeePerKiloWeight: uint32(r.Int63()), CsvDelay: uint16(r.Int31()), MaxAcceptedHTLCs: uint16(r.Int31()), - ChannelFlags: byte(r.Int31()), + ChannelFlags: FundingFlag(uint8(r.Int31())), } if _, err := r.Read(req.ChainHash[:]); err != nil { diff --git a/lnwire/open_channel.go b/lnwire/open_channel.go index 1029cbdd..9f7305e7 100644 --- a/lnwire/open_channel.go +++ b/lnwire/open_channel.go @@ -8,6 +8,17 @@ import ( "github.com/roasbeef/btcutil" ) +// FundingFlag represents the possible bit mask values for the ChannelFlags +// field within the OpenChannel struct. +type FundingFlag uint8 + +const ( + // FFAnnounceChannel is a FundingFlag that when set, indicates the + // initiator of a funding flow wishes to announce the channel to the + // greater network. + FFAnnounceChannel FundingFlag = 1 << iota +) + // OpenChannel is the message Alice sends to Bob if we should like to create a // channel with Bob where she's the sole provider of funds to the channel. // Single funder channels simplify the initial funding workflow, are supported @@ -101,7 +112,7 @@ type OpenChannel struct { // channel to specify further behavior surrounding the channel. // Currently, the least significant bit of this bit field indicates the // initiator of the channel wishes to advertise this channel publicly. - ChannelFlags byte + ChannelFlags FundingFlag } // A compile time check to ensure OpenChannel implements the lnwire.Message