Skip to content

Commit

Permalink
lnwire: export ReadElements and WriteElements
Browse files Browse the repository at this point in the history
In this commit, we export the ReadElements and WriteElements functions.
We do this as exporting these functions makes it possible for outside
packages to define serializations which use the BOLT 1.0 wire format.
  • Loading branch information
Roasbeef committed Dec 10, 2018
1 parent 4d647b6 commit e075a68
Show file tree
Hide file tree
Showing 31 changed files with 125 additions and 125 deletions.
4 changes: 2 additions & 2 deletions lnwire/accept_channel.go
Expand Up @@ -98,7 +98,7 @@ var _ Message = (*AcceptChannel)(nil)
//
// This is part of the lnwire.Message interface.
func (a *AcceptChannel) Encode(w io.Writer, pver uint32) error {
return writeElements(w,
return WriteElements(w,
a.PendingChannelID[:],
a.DustLimit,
a.MaxValueInFlight,
Expand All @@ -122,7 +122,7 @@ func (a *AcceptChannel) Encode(w io.Writer, pver uint32) error {
//
// This is part of the lnwire.Message interface.
func (a *AcceptChannel) Decode(r io.Reader, pver uint32) error {
return readElements(r,
return ReadElements(r,
a.PendingChannelID[:],
&a.DustLimit,
&a.MaxValueInFlight,
Expand Down
4 changes: 2 additions & 2 deletions lnwire/announcement_signatures.go
Expand Up @@ -52,7 +52,7 @@ var _ Message = (*AnnounceSignatures)(nil)
//
// This is part of the lnwire.Message interface.
func (a *AnnounceSignatures) Decode(r io.Reader, pver uint32) error {
err := readElements(r,
err := ReadElements(r,
&a.ChannelID,
&a.ShortChannelID,
&a.NodeSignature,
Expand Down Expand Up @@ -82,7 +82,7 @@ func (a *AnnounceSignatures) Decode(r io.Reader, pver uint32) error {
//
// This is part of the lnwire.Message interface.
func (a *AnnounceSignatures) Encode(w io.Writer, pver uint32) error {
return writeElements(w,
return WriteElements(w,
a.ChannelID,
a.ShortChannelID,
a.NodeSignature,
Expand Down
6 changes: 3 additions & 3 deletions lnwire/channel_announcement.go
Expand Up @@ -68,7 +68,7 @@ var _ Message = (*ChannelAnnouncement)(nil)
//
// This is part of the lnwire.Message interface.
func (a *ChannelAnnouncement) Decode(r io.Reader, pver uint32) error {
err := readElements(r,
err := ReadElements(r,
&a.NodeSig1,
&a.NodeSig2,
&a.BitcoinSig1,
Expand Down Expand Up @@ -105,7 +105,7 @@ func (a *ChannelAnnouncement) Decode(r io.Reader, pver uint32) error {
//
// This is part of the lnwire.Message interface.
func (a *ChannelAnnouncement) Encode(w io.Writer, pver uint32) error {
return writeElements(w,
return WriteElements(w,
a.NodeSig1,
a.NodeSig2,
a.BitcoinSig1,
Expand Down Expand Up @@ -142,7 +142,7 @@ func (a *ChannelAnnouncement) MaxPayloadLength(pver uint32) uint32 {
func (a *ChannelAnnouncement) DataToSign() ([]byte, error) {
// We should not include the signatures itself.
var w bytes.Buffer
err := writeElements(&w,
err := WriteElements(&w,
a.Features,
a.ChainHash[:],
a.ShortChannelID,
Expand Down
8 changes: 4 additions & 4 deletions lnwire/channel_reestablish.go
Expand Up @@ -71,7 +71,7 @@ var _ Message = (*ChannelReestablish)(nil)
//
// This is part of the lnwire.Message interface.
func (a *ChannelReestablish) Encode(w io.Writer, pver uint32) error {
err := writeElements(w,
err := WriteElements(w,
a.ChanID,
a.NextLocalCommitHeight,
a.RemoteCommitTailHeight,
Expand All @@ -87,7 +87,7 @@ func (a *ChannelReestablish) Encode(w io.Writer, pver uint32) error {
}

// Otherwise, we'll write out the remaining elements.
return writeElements(w, a.LastRemoteCommitSecret[:],
return WriteElements(w, a.LastRemoteCommitSecret[:],
a.LocalUnrevokedCommitPoint)
}

Expand All @@ -96,7 +96,7 @@ func (a *ChannelReestablish) Encode(w io.Writer, pver uint32) error {
//
// This is part of the lnwire.Message interface.
func (a *ChannelReestablish) Decode(r io.Reader, pver uint32) error {
err := readElements(r,
err := ReadElements(r,
&a.ChanID,
&a.NextLocalCommitHeight,
&a.RemoteCommitTailHeight,
Expand Down Expand Up @@ -129,7 +129,7 @@ func (a *ChannelReestablish) Decode(r io.Reader, pver uint32) error {
// We'll conclude by parsing out the commitment point. We don't check
// the error in this case, as it hey included the commit secret, then
// they MUST also include the commit point.
return readElement(r, &a.LocalUnrevokedCommitPoint)
return ReadElement(r, &a.LocalUnrevokedCommitPoint)
}

// MsgType returns the integer uniquely identifying this message type on the
Expand Down
6 changes: 3 additions & 3 deletions lnwire/channel_update.go
Expand Up @@ -93,7 +93,7 @@ var _ Message = (*ChannelUpdate)(nil)
//
// This is part of the lnwire.Message interface.
func (a *ChannelUpdate) Decode(r io.Reader, pver uint32) error {
err := readElements(r,
err := ReadElements(r,
&a.Signature,
a.ChainHash[:],
&a.ShortChannelID,
Expand Down Expand Up @@ -128,7 +128,7 @@ func (a *ChannelUpdate) Decode(r io.Reader, pver uint32) error {
//
// This is part of the lnwire.Message interface.
func (a *ChannelUpdate) Encode(w io.Writer, pver uint32) error {
return writeElements(w,
return WriteElements(w,
a.Signature,
a.ChainHash[:],
a.ShortChannelID,
Expand Down Expand Up @@ -164,7 +164,7 @@ func (a *ChannelUpdate) DataToSign() ([]byte, error) {

// We should not include the signatures itself.
var w bytes.Buffer
err := writeElements(&w,
err := WriteElements(&w,
a.ChainHash[:],
a.ShortChannelID,
a.Timestamp,
Expand Down
4 changes: 2 additions & 2 deletions lnwire/closing_signed.go
Expand Up @@ -49,15 +49,15 @@ var _ Message = (*ClosingSigned)(nil)
//
// This is part of the lnwire.Message interface.
func (c *ClosingSigned) Decode(r io.Reader, pver uint32) error {
return readElements(r, &c.ChannelID, &c.FeeSatoshis, &c.Signature)
return ReadElements(r, &c.ChannelID, &c.FeeSatoshis, &c.Signature)
}

// Encode serializes the target ClosingSigned into the passed io.Writer
// observing the protocol version specified.
//
// This is part of the lnwire.Message interface.
func (c *ClosingSigned) Encode(w io.Writer, pver uint32) error {
return writeElements(w, c.ChannelID, c.FeeSatoshis, c.Signature)
return WriteElements(w, c.ChannelID, c.FeeSatoshis, c.Signature)
}

// MsgType returns the integer uniquely identifying this message type on the
Expand Down
4 changes: 2 additions & 2 deletions lnwire/commit_sig.go
Expand Up @@ -48,7 +48,7 @@ var _ Message = (*CommitSig)(nil)
//
// This is part of the lnwire.Message interface.
func (c *CommitSig) Decode(r io.Reader, pver uint32) error {
return readElements(r,
return ReadElements(r,
&c.ChanID,
&c.CommitSig,
&c.HtlcSigs,
Expand All @@ -60,7 +60,7 @@ func (c *CommitSig) Decode(r io.Reader, pver uint32) error {
//
// This is part of the lnwire.Message interface.
func (c *CommitSig) Encode(w io.Writer, pver uint32) error {
return writeElements(w,
return WriteElements(w,
c.ChanID,
c.CommitSig,
c.HtlcSigs,
Expand Down
4 changes: 2 additions & 2 deletions lnwire/error.go
Expand Up @@ -92,7 +92,7 @@ var _ Message = (*Error)(nil)
//
// This is part of the lnwire.Message interface.
func (c *Error) Decode(r io.Reader, pver uint32) error {
return readElements(r,
return ReadElements(r,
&c.ChanID,
&c.Data,
)
Expand All @@ -103,7 +103,7 @@ func (c *Error) Decode(r io.Reader, pver uint32) error {
//
// This is part of the lnwire.Message interface.
func (c *Error) Encode(w io.Writer, pver uint32) error {
return writeElements(w,
return WriteElements(w,
c.ChanID,
c.Data,
)
Expand Down
4 changes: 2 additions & 2 deletions lnwire/funding_created.go
Expand Up @@ -36,7 +36,7 @@ var _ Message = (*FundingCreated)(nil)
//
// This is part of the lnwire.Message interface.
func (f *FundingCreated) Encode(w io.Writer, pver uint32) error {
return writeElements(w, f.PendingChannelID[:], f.FundingPoint, f.CommitSig)
return WriteElements(w, f.PendingChannelID[:], f.FundingPoint, f.CommitSig)
}

// Decode deserializes the serialized FundingCreated stored in the passed
Expand All @@ -45,7 +45,7 @@ func (f *FundingCreated) Encode(w io.Writer, pver uint32) error {
//
// This is part of the lnwire.Message interface.
func (f *FundingCreated) Decode(r io.Reader, pver uint32) error {
return readElements(r, f.PendingChannelID[:], &f.FundingPoint, &f.CommitSig)
return ReadElements(r, f.PendingChannelID[:], &f.FundingPoint, &f.CommitSig)
}

// MsgType returns the uint32 code which uniquely identifies this message as a
Expand Down
4 changes: 2 additions & 2 deletions lnwire/funding_locked.go
Expand Up @@ -40,7 +40,7 @@ var _ Message = (*FundingLocked)(nil)
//
// This is part of the lnwire.Message interface.
func (c *FundingLocked) Decode(r io.Reader, pver uint32) error {
return readElements(r,
return ReadElements(r,
&c.ChanID,
&c.NextPerCommitmentPoint)
}
Expand All @@ -51,7 +51,7 @@ func (c *FundingLocked) Decode(r io.Reader, pver uint32) error {
//
// This is part of the lnwire.Message interface.
func (c *FundingLocked) Encode(w io.Writer, pver uint32) error {
return writeElements(w,
return WriteElements(w,
c.ChanID,
c.NextPerCommitmentPoint)
}
Expand Down
4 changes: 2 additions & 2 deletions lnwire/funding_signed.go
Expand Up @@ -25,7 +25,7 @@ var _ Message = (*FundingSigned)(nil)
//
// This is part of the lnwire.Message interface.
func (f *FundingSigned) Encode(w io.Writer, pver uint32) error {
return writeElements(w, f.ChanID, f.CommitSig)
return WriteElements(w, f.ChanID, f.CommitSig)
}

// Decode deserializes the serialized FundingSigned stored in the passed
Expand All @@ -34,7 +34,7 @@ func (f *FundingSigned) Encode(w io.Writer, pver uint32) error {
//
// This is part of the lnwire.Message interface.
func (f *FundingSigned) Decode(r io.Reader, pver uint32) error {
return readElements(r, &f.ChanID, &f.CommitSig)
return ReadElements(r, &f.ChanID, &f.CommitSig)
}

// MsgType returns the uint32 code which uniquely identifies this message as a
Expand Down
4 changes: 2 additions & 2 deletions lnwire/gossip_timestamp_range.go
Expand Up @@ -40,7 +40,7 @@ var _ Message = (*GossipTimestampRange)(nil)
//
// This is part of the lnwire.Message interface.
func (g *GossipTimestampRange) Decode(r io.Reader, pver uint32) error {
return readElements(r,
return ReadElements(r,
g.ChainHash[:],
&g.FirstTimestamp,
&g.TimestampRange,
Expand All @@ -52,7 +52,7 @@ func (g *GossipTimestampRange) Decode(r io.Reader, pver uint32) error {
//
// This is part of the lnwire.Message interface.
func (g *GossipTimestampRange) Encode(w io.Writer, pver uint32) error {
return writeElements(w,
return WriteElements(w,
g.ChainHash[:],
g.FirstTimestamp,
g.TimestampRange,
Expand Down
4 changes: 2 additions & 2 deletions lnwire/init_message.go
Expand Up @@ -33,7 +33,7 @@ var _ Message = (*Init)(nil)
//
// This is part of the lnwire.Message interface.
func (msg *Init) Decode(r io.Reader, pver uint32) error {
return readElements(r,
return ReadElements(r,
&msg.GlobalFeatures,
&msg.LocalFeatures,
)
Expand All @@ -44,7 +44,7 @@ func (msg *Init) Decode(r io.Reader, pver uint32) error {
//
// This is part of the lnwire.Message interface.
func (msg *Init) Encode(w io.Writer, pver uint32) error {
return writeElements(w,
return WriteElements(w,
msg.GlobalFeatures,
msg.LocalFeatures,
)
Expand Down

0 comments on commit e075a68

Please sign in to comment.