mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-04-06 02:58:03 +02:00
Merge pull request #2369 from Roasbeef/static-chan-backups-lnwire
lnwire: export ReadElements and WriteElements
This commit is contained in:
commit
2103ebba95
@ -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,
|
||||
@ -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,
|
||||
|
@ -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,
|
||||
@ -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,
|
||||
|
@ -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,
|
||||
@ -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,
|
||||
@ -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,
|
||||
|
@ -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,
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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,
|
||||
@ -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
|
||||
|
@ -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,
|
||||
@ -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,
|
||||
@ -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,
|
||||
|
@ -49,7 +49,7 @@ 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
|
||||
@ -57,7 +57,7 @@ func (c *ClosingSigned) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// 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
|
||||
|
@ -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,
|
||||
@ -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,
|
||||
|
@ -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,
|
||||
)
|
||||
@ -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,
|
||||
)
|
||||
|
@ -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
|
||||
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
@ -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)
|
||||
}
|
||||
|
@ -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
|
||||
@ -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
|
||||
|
@ -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,
|
||||
@ -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,
|
||||
|
@ -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,
|
||||
)
|
||||
@ -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,
|
||||
)
|
||||
|
@ -67,14 +67,14 @@ func (a addressType) AddrLen() uint16 {
|
||||
}
|
||||
}
|
||||
|
||||
// writeElement is a one-stop shop to write the big endian representation of
|
||||
// WriteElement is a one-stop shop to write the big endian representation of
|
||||
// any element which is to be serialized for the wire protocol. The passed
|
||||
// io.Writer should be backed by an appropriately sized byte slice, or be able
|
||||
// to dynamically expand to accommodate additional data.
|
||||
//
|
||||
// TODO(roasbeef): this should eventually draw from a buffer pool for
|
||||
// serialization.
|
||||
func writeElement(w io.Writer, element interface{}) error {
|
||||
func WriteElement(w io.Writer, element interface{}) error {
|
||||
switch e := element.(type) {
|
||||
case ShortChanIDEncoding:
|
||||
var b [1]byte
|
||||
@ -156,7 +156,7 @@ func writeElement(w io.Writer, element interface{}) error {
|
||||
}
|
||||
|
||||
for _, sig := range e {
|
||||
if err := writeElement(w, sig); err != nil {
|
||||
if err := WriteElement(w, sig); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -257,7 +257,7 @@ func writeElement(w io.Writer, element interface{}) error {
|
||||
return err
|
||||
}
|
||||
case FailCode:
|
||||
if err := writeElement(w, uint16(e)); err != nil {
|
||||
if err := WriteElement(w, uint16(e)); err != nil {
|
||||
return err
|
||||
}
|
||||
case ShortChannelID:
|
||||
@ -371,7 +371,7 @@ func writeElement(w io.Writer, element interface{}) error {
|
||||
// length of the addresses.
|
||||
var addrBuf bytes.Buffer
|
||||
for _, address := range e {
|
||||
if err := writeElement(&addrBuf, address); err != nil {
|
||||
if err := WriteElement(&addrBuf, address); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -379,7 +379,7 @@ func writeElement(w io.Writer, element interface{}) error {
|
||||
// With the addresses fully encoded, we can now write out the
|
||||
// number of bytes needed to encode them.
|
||||
addrLen := addrBuf.Len()
|
||||
if err := writeElement(w, uint16(addrLen)); err != nil {
|
||||
if err := WriteElement(w, uint16(addrLen)); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -391,7 +391,7 @@ func writeElement(w io.Writer, element interface{}) error {
|
||||
}
|
||||
}
|
||||
case color.RGBA:
|
||||
if err := writeElements(w, e.R, e.G, e.B); err != nil {
|
||||
if err := WriteElements(w, e.R, e.G, e.B); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -406,17 +406,17 @@ func writeElement(w io.Writer, element interface{}) error {
|
||||
}
|
||||
|
||||
default:
|
||||
return fmt.Errorf("Unknown type in writeElement: %T", e)
|
||||
return fmt.Errorf("Unknown type in WriteElement: %T", e)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// writeElements is writes each element in the elements slice to the passed
|
||||
// io.Writer using writeElement.
|
||||
func writeElements(w io.Writer, elements ...interface{}) error {
|
||||
// WriteElements is writes each element in the elements slice to the passed
|
||||
// io.Writer using WriteElement.
|
||||
func WriteElements(w io.Writer, elements ...interface{}) error {
|
||||
for _, element := range elements {
|
||||
err := writeElement(w, element)
|
||||
err := WriteElement(w, element)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -424,9 +424,9 @@ func writeElements(w io.Writer, elements ...interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// readElement is a one-stop utility function to deserialize any datastructure
|
||||
// ReadElement is a one-stop utility function to deserialize any datastructure
|
||||
// encoded using the serialization format of lnwire.
|
||||
func readElement(r io.Reader, element interface{}) error {
|
||||
func ReadElement(r io.Reader, element interface{}) error {
|
||||
var err error
|
||||
switch e := element.(type) {
|
||||
case *ShortChanIDEncoding:
|
||||
@ -520,7 +520,7 @@ func readElement(r io.Reader, element interface{}) error {
|
||||
if numSigs > 0 {
|
||||
sigs = make([]Sig, numSigs)
|
||||
for i := 0; i < int(numSigs); i++ {
|
||||
if err := readElement(r, &sigs[i]); err != nil {
|
||||
if err := ReadElement(r, &sigs[i]); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -612,7 +612,7 @@ func readElement(r io.Reader, element interface{}) error {
|
||||
Index: uint32(index),
|
||||
}
|
||||
case *FailCode:
|
||||
if err := readElement(r, (*uint16)(e)); err != nil {
|
||||
if err := ReadElement(r, (*uint16)(e)); err != nil {
|
||||
return err
|
||||
}
|
||||
case *ChannelID:
|
||||
@ -766,7 +766,7 @@ func readElement(r io.Reader, element interface{}) error {
|
||||
|
||||
*e = addresses
|
||||
case *color.RGBA:
|
||||
err := readElements(r,
|
||||
err := ReadElements(r,
|
||||
&e.R,
|
||||
&e.G,
|
||||
&e.B,
|
||||
@ -790,18 +790,18 @@ func readElement(r io.Reader, element interface{}) error {
|
||||
}
|
||||
*e = addrBytes[:length]
|
||||
default:
|
||||
return fmt.Errorf("Unknown type in readElement: %T", e)
|
||||
return fmt.Errorf("Unknown type in ReadElement: %T", e)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// readElements deserializes a variable number of elements into the passed
|
||||
// io.Reader, with each element being deserialized according to the readElement
|
||||
// ReadElements deserializes a variable number of elements into the passed
|
||||
// io.Reader, with each element being deserialized according to the ReadElement
|
||||
// function.
|
||||
func readElements(r io.Reader, elements ...interface{}) error {
|
||||
func ReadElements(r io.Reader, elements ...interface{}) error {
|
||||
for _, element := range elements {
|
||||
err := readElement(r, element)
|
||||
err := ReadElement(r, element)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ func TestMaxOutPointIndex(t *testing.T) {
|
||||
}
|
||||
|
||||
var b bytes.Buffer
|
||||
if err := writeElement(&b, op); err == nil {
|
||||
if err := WriteElement(&b, op); err == nil {
|
||||
t.Fatalf("write of outPoint should fail, index exceeds 16-bits")
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ var _ Message = (*NodeAnnouncement)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (a *NodeAnnouncement) Decode(r io.Reader, pver uint32) error {
|
||||
err := readElements(r,
|
||||
err := ReadElements(r,
|
||||
&a.Signature,
|
||||
&a.Features,
|
||||
&a.Timestamp,
|
||||
@ -143,7 +143,7 @@ func (a *NodeAnnouncement) Decode(r io.Reader, pver uint32) error {
|
||||
// observing the protocol version specified.
|
||||
//
|
||||
func (a *NodeAnnouncement) Encode(w io.Writer, pver uint32) error {
|
||||
return writeElements(w,
|
||||
return WriteElements(w,
|
||||
a.Signature,
|
||||
a.Features,
|
||||
a.Timestamp,
|
||||
@ -176,7 +176,7 @@ func (a *NodeAnnouncement) DataToSign() ([]byte, error) {
|
||||
|
||||
// We should not include the signatures itself.
|
||||
var w bytes.Buffer
|
||||
err := writeElements(&w,
|
||||
err := WriteElements(&w,
|
||||
a.Features,
|
||||
a.Timestamp,
|
||||
a.NodeID,
|
||||
|
@ -390,14 +390,14 @@ func (f *FailInvalidOnionVersion) Code() FailCode {
|
||||
//
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailInvalidOnionVersion) Decode(r io.Reader, pver uint32) error {
|
||||
return readElement(r, f.OnionSHA256[:])
|
||||
return ReadElement(r, f.OnionSHA256[:])
|
||||
}
|
||||
|
||||
// Encode writes the failure in bytes stream.
|
||||
//
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailInvalidOnionVersion) Encode(w io.Writer, pver uint32) error {
|
||||
return writeElement(w, f.OnionSHA256[:])
|
||||
return WriteElement(w, f.OnionSHA256[:])
|
||||
}
|
||||
|
||||
// FailInvalidOnionHmac is return if the onion HMAC is incorrect.
|
||||
@ -424,14 +424,14 @@ func (f *FailInvalidOnionHmac) Code() FailCode {
|
||||
//
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailInvalidOnionHmac) Decode(r io.Reader, pver uint32) error {
|
||||
return readElement(r, f.OnionSHA256[:])
|
||||
return ReadElement(r, f.OnionSHA256[:])
|
||||
}
|
||||
|
||||
// Encode writes the failure in bytes stream.
|
||||
//
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailInvalidOnionHmac) Encode(w io.Writer, pver uint32) error {
|
||||
return writeElement(w, f.OnionSHA256[:])
|
||||
return WriteElement(w, f.OnionSHA256[:])
|
||||
}
|
||||
|
||||
// Returns a human readable string describing the target FailureMessage.
|
||||
@ -466,14 +466,14 @@ func (f *FailInvalidOnionKey) Code() FailCode {
|
||||
//
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailInvalidOnionKey) Decode(r io.Reader, pver uint32) error {
|
||||
return readElement(r, f.OnionSHA256[:])
|
||||
return ReadElement(r, f.OnionSHA256[:])
|
||||
}
|
||||
|
||||
// Encode writes the failure in bytes stream.
|
||||
//
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailInvalidOnionKey) Encode(w io.Writer, pver uint32) error {
|
||||
return writeElement(w, f.OnionSHA256[:])
|
||||
return WriteElement(w, f.OnionSHA256[:])
|
||||
}
|
||||
|
||||
// Returns a human readable string describing the target FailureMessage.
|
||||
@ -563,7 +563,7 @@ func (f FailTemporaryChannelFailure) Error() string {
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailTemporaryChannelFailure) Decode(r io.Reader, pver uint32) error {
|
||||
var length uint16
|
||||
err := readElement(r, &length)
|
||||
err := ReadElement(r, &length)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -591,7 +591,7 @@ func (f *FailTemporaryChannelFailure) Encode(w io.Writer, pver uint32) error {
|
||||
payload = bw.Bytes()
|
||||
}
|
||||
|
||||
if err := writeElement(w, uint16(len(payload))); err != nil {
|
||||
if err := WriteElement(w, uint16(len(payload))); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -642,12 +642,12 @@ func (f FailAmountBelowMinimum) Error() string {
|
||||
//
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailAmountBelowMinimum) Decode(r io.Reader, pver uint32) error {
|
||||
if err := readElement(r, &f.HtlcMsat); err != nil {
|
||||
if err := ReadElement(r, &f.HtlcMsat); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var length uint16
|
||||
if err := readElement(r, &length); err != nil {
|
||||
if err := ReadElement(r, &length); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -661,11 +661,11 @@ func (f *FailAmountBelowMinimum) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailAmountBelowMinimum) Encode(w io.Writer, pver uint32) error {
|
||||
if err := writeElement(w, f.HtlcMsat); err != nil {
|
||||
if err := WriteElement(w, f.HtlcMsat); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err := writeElement(w, uint16(f.Update.MaxPayloadLength(pver)))
|
||||
err := WriteElement(w, uint16(f.Update.MaxPayloadLength(pver)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -715,12 +715,12 @@ func (f FailFeeInsufficient) Error() string {
|
||||
//
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailFeeInsufficient) Decode(r io.Reader, pver uint32) error {
|
||||
if err := readElement(r, &f.HtlcMsat); err != nil {
|
||||
if err := ReadElement(r, &f.HtlcMsat); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var length uint16
|
||||
if err := readElement(r, &length); err != nil {
|
||||
if err := ReadElement(r, &length); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -734,11 +734,11 @@ func (f *FailFeeInsufficient) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailFeeInsufficient) Encode(w io.Writer, pver uint32) error {
|
||||
if err := writeElement(w, f.HtlcMsat); err != nil {
|
||||
if err := WriteElement(w, f.HtlcMsat); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err := writeElement(w, uint16(f.Update.MaxPayloadLength(pver)))
|
||||
err := WriteElement(w, uint16(f.Update.MaxPayloadLength(pver)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -788,12 +788,12 @@ func (f *FailIncorrectCltvExpiry) Error() string {
|
||||
//
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailIncorrectCltvExpiry) Decode(r io.Reader, pver uint32) error {
|
||||
if err := readElement(r, &f.CltvExpiry); err != nil {
|
||||
if err := ReadElement(r, &f.CltvExpiry); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var length uint16
|
||||
if err := readElement(r, &length); err != nil {
|
||||
if err := ReadElement(r, &length); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -807,11 +807,11 @@ func (f *FailIncorrectCltvExpiry) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailIncorrectCltvExpiry) Encode(w io.Writer, pver uint32) error {
|
||||
if err := writeElement(w, f.CltvExpiry); err != nil {
|
||||
if err := WriteElement(w, f.CltvExpiry); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err := writeElement(w, uint16(f.Update.MaxPayloadLength(pver)))
|
||||
err := WriteElement(w, uint16(f.Update.MaxPayloadLength(pver)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -855,7 +855,7 @@ func (f *FailExpiryTooSoon) Error() string {
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailExpiryTooSoon) Decode(r io.Reader, pver uint32) error {
|
||||
var length uint16
|
||||
if err := readElement(r, &length); err != nil {
|
||||
if err := ReadElement(r, &length); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -869,7 +869,7 @@ func (f *FailExpiryTooSoon) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailExpiryTooSoon) Encode(w io.Writer, pver uint32) error {
|
||||
err := writeElement(w, uint16(f.Update.MaxPayloadLength(pver)))
|
||||
err := WriteElement(w, uint16(f.Update.MaxPayloadLength(pver)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -919,12 +919,12 @@ func (f FailChannelDisabled) Error() string {
|
||||
//
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailChannelDisabled) Decode(r io.Reader, pver uint32) error {
|
||||
if err := readElement(r, &f.Flags); err != nil {
|
||||
if err := ReadElement(r, &f.Flags); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var length uint16
|
||||
if err := readElement(r, &length); err != nil {
|
||||
if err := ReadElement(r, &length); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -938,11 +938,11 @@ func (f *FailChannelDisabled) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailChannelDisabled) Encode(w io.Writer, pver uint32) error {
|
||||
if err := writeElement(w, f.Flags); err != nil {
|
||||
if err := WriteElement(w, f.Flags); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err := writeElement(w, uint16(f.Update.MaxPayloadLength(pver)))
|
||||
err := WriteElement(w, uint16(f.Update.MaxPayloadLength(pver)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -986,14 +986,14 @@ func (f *FailFinalIncorrectCltvExpiry) Code() FailCode {
|
||||
//
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailFinalIncorrectCltvExpiry) Decode(r io.Reader, pver uint32) error {
|
||||
return readElement(r, &f.CltvExpiry)
|
||||
return ReadElement(r, &f.CltvExpiry)
|
||||
}
|
||||
|
||||
// Encode writes the failure in bytes stream.
|
||||
//
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailFinalIncorrectCltvExpiry) Encode(w io.Writer, pver uint32) error {
|
||||
return writeElement(w, f.CltvExpiry)
|
||||
return WriteElement(w, f.CltvExpiry)
|
||||
}
|
||||
|
||||
// FailFinalIncorrectHtlcAmount is returned if the amt_to_forward is higher
|
||||
@ -1032,14 +1032,14 @@ func (f *FailFinalIncorrectHtlcAmount) Code() FailCode {
|
||||
//
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailFinalIncorrectHtlcAmount) Decode(r io.Reader, pver uint32) error {
|
||||
return readElement(r, &f.IncomingHTLCAmount)
|
||||
return ReadElement(r, &f.IncomingHTLCAmount)
|
||||
}
|
||||
|
||||
// Encode writes the failure in bytes stream.
|
||||
//
|
||||
// NOTE: Part of the Serializable interface.
|
||||
func (f *FailFinalIncorrectHtlcAmount) Encode(w io.Writer, pver uint32) error {
|
||||
return writeElement(w, f.IncomingHTLCAmount)
|
||||
return WriteElement(w, f.IncomingHTLCAmount)
|
||||
}
|
||||
|
||||
// FailExpiryTooFar is returned if the CLTV expiry in the HTLC is too far in the
|
||||
@ -1068,7 +1068,7 @@ func DecodeFailure(r io.Reader, pver uint32) (FailureMessage, error) {
|
||||
// First, we'll parse out the encapsulated failure message itself. This
|
||||
// is a 2 byte length followed by the payload itself.
|
||||
var failureLength uint16
|
||||
if err := readElement(r, &failureLength); err != nil {
|
||||
if err := ReadElement(r, &failureLength); err != nil {
|
||||
return nil, fmt.Errorf("unable to read error len: %v", err)
|
||||
}
|
||||
if failureLength > failureMessageLength {
|
||||
@ -1149,7 +1149,7 @@ func EncodeFailure(w io.Writer, failure FailureMessage, pver uint32) error {
|
||||
// messages are fixed size.
|
||||
pad := make([]byte, failureMessageLength-len(failureMessage))
|
||||
|
||||
return writeElements(w,
|
||||
return WriteElements(w,
|
||||
uint16(len(failureMessage)),
|
||||
failureMessage,
|
||||
uint16(len(pad)),
|
||||
|
@ -134,7 +134,7 @@ var _ Message = (*OpenChannel)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (o *OpenChannel) Encode(w io.Writer, pver uint32) error {
|
||||
return writeElements(w,
|
||||
return WriteElements(w,
|
||||
o.ChainHash[:],
|
||||
o.PendingChannelID[:],
|
||||
o.FundingAmount,
|
||||
@ -162,7 +162,7 @@ func (o *OpenChannel) Encode(w io.Writer, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (o *OpenChannel) Decode(r io.Reader, pver uint32) error {
|
||||
return readElements(r,
|
||||
return ReadElements(r,
|
||||
o.ChainHash[:],
|
||||
o.PendingChannelID[:],
|
||||
&o.FundingAmount,
|
||||
|
@ -35,7 +35,7 @@ var _ Message = (*Ping)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (p *Ping) Decode(r io.Reader, pver uint32) error {
|
||||
return readElements(r,
|
||||
return ReadElements(r,
|
||||
&p.NumPongBytes,
|
||||
&p.PaddingBytes)
|
||||
}
|
||||
@ -45,7 +45,7 @@ func (p *Ping) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (p *Ping) Encode(w io.Writer, pver uint32) error {
|
||||
return writeElements(w,
|
||||
return WriteElements(w,
|
||||
p.NumPongBytes,
|
||||
p.PaddingBytes)
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ var _ Message = (*Pong)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (p *Pong) Decode(r io.Reader, pver uint32) error {
|
||||
return readElements(r,
|
||||
return ReadElements(r,
|
||||
&p.PongBytes,
|
||||
)
|
||||
}
|
||||
@ -41,7 +41,7 @@ func (p *Pong) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (p *Pong) Encode(w io.Writer, pver uint32) error {
|
||||
return writeElements(w,
|
||||
return WriteElements(w,
|
||||
p.PongBytes,
|
||||
)
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ var _ Message = (*QueryChannelRange)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (q *QueryChannelRange) Decode(r io.Reader, pver uint32) error {
|
||||
return readElements(r,
|
||||
return ReadElements(r,
|
||||
q.ChainHash[:],
|
||||
&q.FirstBlockHeight,
|
||||
&q.NumBlocks,
|
||||
@ -52,7 +52,7 @@ func (q *QueryChannelRange) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (q *QueryChannelRange) Encode(w io.Writer, pver uint32) error {
|
||||
return writeElements(w,
|
||||
return WriteElements(w,
|
||||
q.ChainHash[:],
|
||||
q.FirstBlockHeight,
|
||||
q.NumBlocks,
|
||||
|
@ -89,7 +89,7 @@ var _ Message = (*QueryShortChanIDs)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (q *QueryShortChanIDs) Decode(r io.Reader, pver uint32) error {
|
||||
err := readElements(r, q.ChainHash[:])
|
||||
err := ReadElements(r, q.ChainHash[:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -107,7 +107,7 @@ func decodeShortChanIDs(r io.Reader) (ShortChanIDEncoding, []ShortChannelID, err
|
||||
// First, we'll attempt to read the number of bytes in the body of the
|
||||
// set of encoded short channel ID's.
|
||||
var numBytesResp uint16
|
||||
err := readElements(r, &numBytesResp)
|
||||
err := ReadElements(r, &numBytesResp)
|
||||
if err != nil {
|
||||
return 0, nil, err
|
||||
}
|
||||
@ -159,7 +159,7 @@ func decodeShortChanIDs(r io.Reader) (ShortChanIDEncoding, []ShortChannelID, err
|
||||
shortChanIDs := make([]ShortChannelID, numShortChanIDs)
|
||||
bodyReader := bytes.NewReader(queryBody)
|
||||
for i := 0; i < numShortChanIDs; i++ {
|
||||
if err := readElements(bodyReader, &shortChanIDs[i]); err != nil {
|
||||
if err := ReadElements(bodyReader, &shortChanIDs[i]); err != nil {
|
||||
return 0, nil, fmt.Errorf("unable to parse "+
|
||||
"short chan ID: %v", err)
|
||||
}
|
||||
@ -196,7 +196,7 @@ func decodeShortChanIDs(r io.Reader) (ShortChanIDEncoding, []ShortChannelID, err
|
||||
// We'll now attempt to read the next short channel ID
|
||||
// encoded in the payload.
|
||||
var cid ShortChannelID
|
||||
err := readElements(limitedDecompressor, &cid)
|
||||
err := ReadElements(limitedDecompressor, &cid)
|
||||
|
||||
switch {
|
||||
// If we get an EOF error, then that either means we've
|
||||
@ -246,7 +246,7 @@ func decodeShortChanIDs(r io.Reader) (ShortChanIDEncoding, []ShortChannelID, err
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (q *QueryShortChanIDs) Encode(w io.Writer, pver uint32) error {
|
||||
// First, we'll write out the chain hash.
|
||||
err := writeElements(w, q.ChainHash[:])
|
||||
err := WriteElements(w, q.ChainHash[:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -277,20 +277,20 @@ func encodeShortChanIDs(w io.Writer, encodingType ShortChanIDEncoding,
|
||||
// body. We add 1 as the response will have the encoding type
|
||||
// prepended to it.
|
||||
numBytesBody := uint16(len(shortChanIDs)*8) + 1
|
||||
if err := writeElements(w, numBytesBody); err != nil {
|
||||
if err := WriteElements(w, numBytesBody); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// We'll then write out the encoding that that follows the
|
||||
// actual encoded short channel ID's.
|
||||
if err := writeElements(w, encodingType); err != nil {
|
||||
if err := WriteElements(w, encodingType); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Now that we know they're sorted, we can write out each short
|
||||
// channel ID to the buffer.
|
||||
for _, chanID := range shortChanIDs {
|
||||
if err := writeElements(w, chanID); err != nil {
|
||||
if err := WriteElements(w, chanID); err != nil {
|
||||
return fmt.Errorf("unable to write short chan "+
|
||||
"ID: %v", err)
|
||||
}
|
||||
@ -314,7 +314,7 @@ func encodeShortChanIDs(w io.Writer, encodingType ShortChanIDEncoding,
|
||||
// Next, we'll write out all the channel ID's directly into the
|
||||
// zlib writer, which will do compressing on the fly.
|
||||
for _, chanID := range shortChanIDs {
|
||||
err := writeElements(zlibWriter, chanID)
|
||||
err := WriteElements(zlibWriter, chanID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to write short chan "+
|
||||
"ID: %v", err)
|
||||
@ -336,10 +336,10 @@ func encodeShortChanIDs(w io.Writer, encodingType ShortChanIDEncoding,
|
||||
|
||||
// Finally, we can write out the number of bytes, the
|
||||
// compression type, and finally the buffer itself.
|
||||
if err := writeElements(w, uint16(numBytesBody)); err != nil {
|
||||
if err := WriteElements(w, uint16(numBytesBody)); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := writeElements(w, encodingType); err != nil {
|
||||
if err := WriteElements(w, encodingType); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ func (c *ReplyChannelRange) Decode(r io.Reader, pver uint32) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := readElements(r, &c.Complete); err != nil {
|
||||
if err := ReadElements(r, &c.Complete); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ func (c *ReplyChannelRange) Encode(w io.Writer, pver uint32) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := writeElements(w, c.Complete); err != nil {
|
||||
if err := WriteElements(w, c.Complete); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ var _ Message = (*ReplyShortChanIDsEnd)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *ReplyShortChanIDsEnd) Decode(r io.Reader, pver uint32) error {
|
||||
return readElements(r,
|
||||
return ReadElements(r,
|
||||
c.ChainHash[:],
|
||||
&c.Complete,
|
||||
)
|
||||
@ -49,7 +49,7 @@ func (c *ReplyShortChanIDsEnd) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *ReplyShortChanIDsEnd) Encode(w io.Writer, pver uint32) error {
|
||||
return writeElements(w,
|
||||
return WriteElements(w,
|
||||
c.ChainHash[:],
|
||||
c.Complete,
|
||||
)
|
||||
|
@ -46,7 +46,7 @@ var _ Message = (*RevokeAndAck)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *RevokeAndAck) Decode(r io.Reader, pver uint32) error {
|
||||
return readElements(r,
|
||||
return ReadElements(r,
|
||||
&c.ChanID,
|
||||
c.Revocation[:],
|
||||
&c.NextRevocationKey,
|
||||
@ -58,7 +58,7 @@ func (c *RevokeAndAck) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *RevokeAndAck) Encode(w io.Writer, pver uint32) error {
|
||||
return writeElements(w,
|
||||
return WriteElements(w,
|
||||
c.ChanID,
|
||||
c.Revocation[:],
|
||||
c.NextRevocationKey,
|
||||
|
@ -39,7 +39,7 @@ var _ Message = (*Shutdown)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (s *Shutdown) Decode(r io.Reader, pver uint32) error {
|
||||
return readElements(r, &s.ChannelID, &s.Address)
|
||||
return ReadElements(r, &s.ChannelID, &s.Address)
|
||||
}
|
||||
|
||||
// Encode serializes the target Shutdown into the passed io.Writer observing
|
||||
@ -47,7 +47,7 @@ func (s *Shutdown) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (s *Shutdown) Encode(w io.Writer, pver uint32) error {
|
||||
return writeElements(w, s.ChannelID, s.Address)
|
||||
return WriteElements(w, s.ChannelID, s.Address)
|
||||
}
|
||||
|
||||
// MsgType returns the integer uniquely identifying this message type on the
|
||||
|
@ -66,7 +66,7 @@ var _ Message = (*UpdateAddHTLC)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *UpdateAddHTLC) Decode(r io.Reader, pver uint32) error {
|
||||
return readElements(r,
|
||||
return ReadElements(r,
|
||||
&c.ChanID,
|
||||
&c.ID,
|
||||
&c.Amount,
|
||||
@ -81,7 +81,7 @@ func (c *UpdateAddHTLC) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *UpdateAddHTLC) Encode(w io.Writer, pver uint32) error {
|
||||
return writeElements(w,
|
||||
return WriteElements(w,
|
||||
c.ChanID,
|
||||
c.ID,
|
||||
c.Amount,
|
||||
|
@ -35,7 +35,7 @@ var _ Message = (*UpdateFailHTLC)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *UpdateFailHTLC) Decode(r io.Reader, pver uint32) error {
|
||||
return readElements(r,
|
||||
return ReadElements(r,
|
||||
&c.ChanID,
|
||||
&c.ID,
|
||||
&c.Reason,
|
||||
@ -47,7 +47,7 @@ func (c *UpdateFailHTLC) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *UpdateFailHTLC) Encode(w io.Writer, pver uint32) error {
|
||||
return writeElements(w,
|
||||
return WriteElements(w,
|
||||
c.ChanID,
|
||||
c.ID,
|
||||
c.Reason,
|
||||
|
@ -35,7 +35,7 @@ var _ Message = (*UpdateFailMalformedHTLC)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *UpdateFailMalformedHTLC) Decode(r io.Reader, pver uint32) error {
|
||||
return readElements(r,
|
||||
return ReadElements(r,
|
||||
&c.ChanID,
|
||||
&c.ID,
|
||||
c.ShaOnionBlob[:],
|
||||
@ -48,7 +48,7 @@ func (c *UpdateFailMalformedHTLC) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *UpdateFailMalformedHTLC) Encode(w io.Writer, pver uint32) error {
|
||||
return writeElements(w,
|
||||
return WriteElements(w,
|
||||
c.ChanID,
|
||||
c.ID,
|
||||
c.ShaOnionBlob[:],
|
||||
|
@ -35,7 +35,7 @@ var _ Message = (*UpdateFee)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *UpdateFee) Decode(r io.Reader, pver uint32) error {
|
||||
return readElements(r,
|
||||
return ReadElements(r,
|
||||
&c.ChanID,
|
||||
&c.FeePerKw,
|
||||
)
|
||||
@ -46,7 +46,7 @@ func (c *UpdateFee) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *UpdateFee) Encode(w io.Writer, pver uint32) error {
|
||||
return writeElements(w,
|
||||
return WriteElements(w,
|
||||
c.ChanID,
|
||||
c.FeePerKw,
|
||||
)
|
||||
|
@ -41,7 +41,7 @@ var _ Message = (*UpdateFulfillHTLC)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *UpdateFulfillHTLC) Decode(r io.Reader, pver uint32) error {
|
||||
return readElements(r,
|
||||
return ReadElements(r,
|
||||
&c.ChanID,
|
||||
&c.ID,
|
||||
c.PaymentPreimage[:],
|
||||
@ -53,7 +53,7 @@ func (c *UpdateFulfillHTLC) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *UpdateFulfillHTLC) Encode(w io.Writer, pver uint32) error {
|
||||
return writeElements(w,
|
||||
return WriteElements(w,
|
||||
c.ChanID,
|
||||
c.ID,
|
||||
c.PaymentPreimage[:],
|
||||
|
Loading…
x
Reference in New Issue
Block a user