lnwire: on Message interface convert Command to MsgType

This commit modifies the Message interface to convert the Command
method to a MsgType method that uses a new set of message type for all
the defined messages. These new messages types nearly exactly match the
message types used within the current draft of the BOLT specifications.
This commit is contained in:
Olaoluwa Osuntokun 2017-04-19 15:57:43 -07:00
parent bcd142bc30
commit f6b3c25f95
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
21 changed files with 119 additions and 151 deletions

@ -66,12 +66,12 @@ func (a *AnnounceSignatures) Encode(w io.Writer, pver uint32) error {
) )
} }
// Command returns the integer uniquely identifying this message type on the // MsgType returns the integer uniquely identifying this message type on the
// wire. // wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (a *AnnounceSignatures) Command() uint32 { func (a *AnnounceSignatures) MsgType() MessageType {
return CmdAnnounceSignatures return MsgAnnounceSignatures
} }
// MaxPayloadLength returns the maximum allowed payload size for this message // MaxPayloadLength returns the maximum allowed payload size for this message

@ -79,12 +79,12 @@ func (a *ChannelAnnouncement) Encode(w io.Writer, pver uint32) error {
) )
} }
// Command returns the integer uniquely identifying this message type on the // MsgType returns the integer uniquely identifying this message type on the
// wire. // wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (a *ChannelAnnouncement) Command() uint32 { func (a *ChannelAnnouncement) MsgType() MessageType {
return CmdChannelAnnouncement return MsgChannelAnnouncement
} }
// MaxPayloadLength returns the maximum allowed payload size for this message // MaxPayloadLength returns the maximum allowed payload size for this message

@ -84,12 +84,12 @@ func (a *ChannelUpdate) Encode(w io.Writer, pver uint32) error {
) )
} }
// Command returns the integer uniquely identifying this message type on the // MsgType returns the integer uniquely identifying this message type on the
// wire. // wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (a *ChannelUpdate) Command() uint32 { func (a *ChannelUpdate) MsgType() MessageType {
return CmdChannelUpdate return MsgChannelUpdate
} }
// MaxPayloadLength returns the maximum allowed payload size for this message // MaxPayloadLength returns the maximum allowed payload size for this message

@ -41,8 +41,6 @@ var _ Message = (*CloseComplete)(nil)
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (c *CloseComplete) Decode(r io.Reader, pver uint32) error { func (c *CloseComplete) Decode(r io.Reader, pver uint32) error {
// ChannelPoint (8)
// ResponderCloseSig (73)
return readElements(r, return readElements(r,
&c.ChannelPoint, &c.ChannelPoint,
&c.ResponderCloseSig) &c.ResponderCloseSig)
@ -53,19 +51,17 @@ func (c *CloseComplete) Decode(r io.Reader, pver uint32) error {
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (c *CloseComplete) Encode(w io.Writer, pver uint32) error { func (c *CloseComplete) Encode(w io.Writer, pver uint32) error {
// ChannelPoint (8)
// ResponderCloseSig (73)
return writeElements(w, return writeElements(w,
c.ChannelPoint, c.ChannelPoint,
c.ResponderCloseSig) c.ResponderCloseSig)
} }
// Command returns the integer uniquely identifying this message type on the // MsgType returns the integer uniquely identifying this message type on the
// wire. // wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (c *CloseComplete) Command() uint32 { func (c *CloseComplete) MsgType() MessageType {
return CmdCloseComplete return MsgCloseComplete
} }
// MaxPayloadLength returns the maximum allowed payload size for a CloseComplete // MaxPayloadLength returns the maximum allowed payload size for a CloseComplete

@ -1,8 +1,6 @@
package lnwire package lnwire
import ( import (
"fmt"
"github.com/roasbeef/btcd/btcec" "github.com/roasbeef/btcd/btcec"
"github.com/roasbeef/btcutil" "github.com/roasbeef/btcutil"
@ -69,12 +67,12 @@ func (c *CloseRequest) Encode(w io.Writer, pver uint32) error {
c.Fee) c.Fee)
} }
// Command returns the integer uniquely identifying this message type on the // MsgType returns the integer uniquely identifying this message type on the
// wire. // wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (c *CloseRequest) Command() uint32 { func (c *CloseRequest) MsgType() MessageType {
return CmdCloseRequest return MsgCloseRequest
} }
// MaxPayloadLength returns the maximum allowed payload size for this message // MaxPayloadLength returns the maximum allowed payload size for this message

@ -60,12 +60,12 @@ func (c *CommitSig) Encode(w io.Writer, pver uint32) error {
) )
} }
// Command returns the integer uniquely identifying this message type on the // MsgType returns the integer uniquely identifying this message type on the
// wire. // wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (c *CommitSig) Command() uint32 { func (c *CommitSig) MsgType() MessageType {
return CmdCommitSig return MsgCommitSig
} }
// MaxPayloadLength returns the maximum allowed payload size for a // MaxPayloadLength returns the maximum allowed payload size for a

@ -1,9 +1,7 @@
package lnwire package lnwire
import ( import (
"fmt"
"io" "io"
"math"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
) )
@ -92,12 +90,12 @@ func (c *Error) Encode(w io.Writer, pver uint32) error {
) )
} }
// Command returns the integer uniquely identifying an Error message on the // MsgType returns the integer uniquely identifying an Error message on the
// wire. // wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (c *Error) Command() uint32 { func (c *Error) MsgType() MessageType {
return CmdError return MsgError
} }
// MaxPayloadLength returns the maximum allowed payload size for a Error // MaxPayloadLength returns the maximum allowed payload size for a Error

@ -1,7 +1,6 @@
package lnwire package lnwire
import ( import (
"fmt"
"io" "io"
"github.com/roasbeef/btcd/btcec" "github.com/roasbeef/btcd/btcec"
@ -57,12 +56,12 @@ func (c *FundingLocked) Encode(w io.Writer, pver uint32) error {
c.NextPerCommitmentPoint) c.NextPerCommitmentPoint)
} }
// Command returns the uint32 code which uniquely identifies this message as a // MsgType returns the uint32 code which uniquely identifies this message as a
// FundingLocked message on the wire. // FundingLocked message on the wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (c *FundingLocked) Command() uint32 { func (c *FundingLocked) MsgType() MessageType {
return CmdFundingLocked return MsgFundingLocked
} }
// MaxPayloadLength returns the maximum allowed payload length for a // MaxPayloadLength returns the maximum allowed payload length for a

@ -1,9 +1,6 @@
package lnwire package lnwire
import ( import "io"
"github.com/go-errors/errors"
"io"
)
// Init is the first message reveals the features supported or required by this // Init is the first message reveals the features supported or required by this
// node. Nodes wait for receipt of the other's features to simplify error // node. Nodes wait for receipt of the other's features to simplify error
@ -27,23 +24,21 @@ func NewInitMessage(gf, lf *FeatureVector) *Init {
} }
} }
// A compile time check to ensure Init implements the lnwire.Message
// interface.
var _ Message = (*Init)(nil)
// Decode deserializes a serialized Init message stored in the passed // Decode deserializes a serialized Init message stored in the passed
// io.Reader observing the specified protocol version. // io.Reader observing the specified protocol version.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (msg *Init) Decode(r io.Reader, pver uint32) error { func (msg *Init) Decode(r io.Reader, pver uint32) error {
// LocalFeatures(~)
// GlobalFeatures(~)
return readElements(r, return readElements(r,
&msg.LocalFeatures, &msg.LocalFeatures,
&msg.GlobalFeatures, &msg.GlobalFeatures,
) )
} }
// A compile time check to ensure Init implements the lnwire.Message
// interface.
var _ Message = (*Init)(nil)
// Encode serializes the target Init into the passed io.Writer observing // Encode serializes the target Init into the passed io.Writer observing
// the protocol version specified. // the protocol version specified.
// //
@ -55,12 +50,12 @@ func (msg *Init) Encode(w io.Writer, pver uint32) error {
) )
} }
// Command returns the integer uniquely identifying this message type on the // MsgType returns the integer uniquely identifying this message type on the
// wire. // wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (msg *Init) Command() uint32 { func (msg *Init) MsgType() MessageType {
return CmdInit return MsgInit
} }
// MaxPayloadLength returns the maximum allowed payload size for a Init // MaxPayloadLength returns the maximum allowed payload size for a Init

@ -4,10 +4,9 @@ package lnwire
import ( import (
"bytes" "bytes"
"encoding/binary"
"fmt" "fmt"
"io" "io"
"github.com/roasbeef/btcd/wire"
) )
// MessageHeaderSize is the number of bytes in a lightning message header. // MessageHeaderSize is the number of bytes in a lightning message header.
@ -19,53 +18,42 @@ const MessageHeaderSize = 12
// MaxMessagePayload is the maximum bytes a message can be regardless of other // MaxMessagePayload is the maximum bytes a message can be regardless of other
// individual limits imposed by messages themselves. // individual limits imposed by messages themselves.
// Commands used in lightning message headers which detail the type of message.
// TODO(roasbeef): update with latest type numbering from spec
const (
CmdInit = uint32(1)
// Commands for opening a channel funded by one party (single funder).
CmdSingleFundingRequest = uint32(100)
CmdSingleFundingResponse = uint32(110)
CmdSingleFundingComplete = uint32(120)
CmdSingleFundingSignComplete = uint32(130)
// Command for locking a funded channel
CmdFundingLocked = uint32(200)
const MaxMessagePayload = 65535 // 65KB const MaxMessagePayload = 65535 // 65KB
// Commands for the workflow of cooperatively closing an active channel. // MessageType is the unique 2 byte big-endian integer that indicates the type
CmdCloseRequest = uint32(300) // of message on the wire. All messages have a very simple header which
CmdCloseComplete = uint32(310) // consists simply of 2-byte message type. We omit a length field, and checksum
// as the Lighting Protocol is intended to be encapsulated within a
// confidential+authenticated cryptographic messaging protocol.
type MessageType uint16
// Commands for negotiating HTLCs. const (
CmdUpdateAddHTLC = uint32(1000) MsgInit MessageType = 16
CmdUpdateFufillHTLC = uint32(1010) MsgError = 17
CmdUpdateFailHTLC = uint32(1020) MsgPing = 18
MsgPong = 19
// Commands for modifying commitment transactions. MsgSingleFundingRequest = 32
CmdCommitSig = uint32(2000) MsgSingleFundingResponse = 33
CmdRevokeAndAck = uint32(2010) MsgSingleFundingComplete = 34
MsgSingleFundingSignComplete = 35
// Commands for reporting protocol errors. MsgFundingLocked = 36
CmdError = uint32(4000) MsgCloseRequest = 39
MsgCloseComplete = 40
// Commands for discovery service. MsgUpdateAddHTLC = 128
CmdChannelAnnouncement = uint32(5000) MsgUpdateFufillHTLC = 130
CmdChannelUpdateAnnouncement = uint32(5010) MsgUpdateFailHTLC = 131
CmdNodeAnnouncement = uint32(5020) MsgCommitSig = 132
CmdAnnounceSignatures = uint32(5030) MsgRevokeAndAck = 133
MsgChannelAnnouncement = 256
// Commands for connection keep-alive. MsgNodeAnnouncement = 257
CmdPing = uint32(6000) MsgChannelUpdate = 258
CmdPong = uint32(6010) MsgAnnounceSignatures = 259
) )
// UnknownMessage is an implementation of the error interface that allows the // UnknownMessage is an implementation of the error interface that allows the
// creation of an error in response to an unknown message. // creation of an error in response to an unknown message.
type UnknownMessage struct { type UnknownMessage struct {
messageType uint32 messageType MessageType
} }
// Error returns a human readable string describing the error. // Error returns a human readable string describing the error.
@ -82,58 +70,58 @@ func (u *UnknownMessage) Error() string {
type Message interface { type Message interface {
Decode(io.Reader, uint32) error Decode(io.Reader, uint32) error
Encode(io.Writer, uint32) error Encode(io.Writer, uint32) error
Command() uint32 MsgType() MessageType
MaxPayloadLength(uint32) uint32 MaxPayloadLength(uint32) uint32
} }
// makeEmptyMessage creates a new empty message of the proper concrete type // makeEmptyMessage creates a new empty message of the proper concrete type
// based on the command ID. // based on the passed message type.
func makeEmptyMessage(command uint32) (Message, error) { func makeEmptyMessage(msgType MessageType) (Message, error) {
var msg Message var msg Message
switch command { switch msgType {
case CmdInit: case MsgInit:
msg = &Init{} msg = &Init{}
case CmdSingleFundingRequest: case MsgSingleFundingRequest:
msg = &SingleFundingRequest{} msg = &SingleFundingRequest{}
case CmdSingleFundingResponse: case MsgSingleFundingResponse:
msg = &SingleFundingResponse{} msg = &SingleFundingResponse{}
case CmdSingleFundingComplete: case MsgSingleFundingComplete:
msg = &SingleFundingComplete{} msg = &SingleFundingComplete{}
case CmdSingleFundingSignComplete: case MsgSingleFundingSignComplete:
msg = &SingleFundingSignComplete{} msg = &SingleFundingSignComplete{}
case CmdFundingLocked: case MsgFundingLocked:
msg = &FundingLocked{} msg = &FundingLocked{}
case CmdCloseRequest: case MsgCloseRequest:
msg = &CloseRequest{} msg = &CloseRequest{}
case CmdCloseComplete: case MsgCloseComplete:
msg = &CloseComplete{} msg = &CloseComplete{}
case CmdUpdateAddHTLC: case MsgUpdateAddHTLC:
msg = &UpdateAddHTLC{} msg = &UpdateAddHTLC{}
case CmdUpdateFailHTLC: case MsgUpdateFailHTLC:
msg = &UpdateFailHTLC{} msg = &UpdateFailHTLC{}
case CmdUpdateFufillHTLC: case MsgUpdateFufillHTLC:
msg = &UpdateFufillHTLC{} msg = &UpdateFufillHTLC{}
case CmdCommitSig: case MsgCommitSig:
msg = &CommitSig{} msg = &CommitSig{}
case CmdRevokeAndAck: case MsgRevokeAndAck:
msg = &RevokeAndAck{} msg = &RevokeAndAck{}
case CmdError: case MsgError:
msg = &Error{} msg = &Error{}
case CmdChannelAnnouncement: case MsgChannelAnnouncement:
msg = &ChannelAnnouncement{} msg = &ChannelAnnouncement{}
case CmdChannelUpdateAnnouncement: case MsgChannelUpdate:
msg = &ChannelUpdateAnnouncement{} msg = &ChannelUpdate{}
case CmdNodeAnnouncement: case MsgNodeAnnouncement:
msg = &NodeAnnouncement{} msg = &NodeAnnouncement{}
case CmdPing: case MsgPing:
msg = &Ping{} msg = &Ping{}
case CmdAnnounceSignatures: case MsgAnnounceSignatures:
msg = &AnnounceSignatures{} msg = &AnnounceSignatures{}
case CmdPong: case MsgPong:
msg = &Pong{} msg = &Pong{}
default: default:
return nil, fmt.Errorf("unhandled command [%d]", command) return nil, fmt.Errorf("unknown message type [%d]", msgType)
} }
return msg, nil return msg, nil

@ -140,12 +140,12 @@ func (a *NodeAnnouncement) Encode(w io.Writer, pver uint32) error {
) )
} }
// Command returns the integer uniquely identifying this message type on the // MsgType returns the integer uniquely identifying this message type on the
// wire. // wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (a *NodeAnnouncement) Command() uint32 { func (a *NodeAnnouncement) MsgType() MessageType {
return CmdNodeAnnouncement return MsgNodeAnnouncement
} }
// MaxPayloadLength returns the maximum allowed payload size for this message // MaxPayloadLength returns the maximum allowed payload size for this message

@ -50,12 +50,12 @@ func (p *Ping) Encode(w io.Writer, pver uint32) error {
p.PaddingBytes) p.PaddingBytes)
} }
// Command returns the integer uniquely identifying this message type on the // MsgType returns the integer uniquely identifying this message type on the
// wire. // wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (p *Ping) Command() uint32 { func (p *Ping) MsgType() MessageType {
return CmdPing return MsgPing
} }
// MaxPayloadLength returns the maximum allowed payload size for a Ping // MaxPayloadLength returns the maximum allowed payload size for a Ping

@ -46,12 +46,12 @@ func (p *Pong) Encode(w io.Writer, pver uint32) error {
) )
} }
// Command returns the integer uniquely identifying this message type on the // MsgType returns the integer uniquely identifying this message type on the
// wire. // wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (p *Pong) Command() uint32 { func (p *Pong) MsgType() MessageType {
return CmdPong return MsgPong
} }
// MaxPayloadLength returns the maximum allowed payload size for a Pong // MaxPayloadLength returns the maximum allowed payload size for a Pong

@ -78,12 +78,12 @@ func (c *RevokeAndAck) Encode(w io.Writer, pver uint32) error {
) )
} }
// Command returns the integer uniquely identifying this message type on the // MsgType returns the integer uniquely identifying this message type on the
// wire. // wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (c *RevokeAndAck) Command() uint32 { func (c *RevokeAndAck) MsgType() MessageType {
return CmdRevokeAndAck return MsgRevokeAndAck
} }
// MaxPayloadLength returns the maximum allowed payload size for a // MaxPayloadLength returns the maximum allowed payload size for a

@ -1,8 +1,6 @@
package lnwire package lnwire
import ( import (
"bytes"
"fmt"
"io" "io"
"github.com/roasbeef/btcd/btcec" "github.com/roasbeef/btcd/btcec"
@ -86,12 +84,12 @@ func (s *SingleFundingComplete) Encode(w io.Writer, pver uint32) error {
s.StateHintObsfucator[:]) s.StateHintObsfucator[:])
} }
// Command returns the uint32 code which uniquely identifies this message as a // MsgType returns the uint32 code which uniquely identifies this message as a
// SingleFundingComplete on the wire. // SingleFundingComplete on the wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (s *SingleFundingComplete) Command() uint32 { func (s *SingleFundingComplete) MsgType() MessageType {
return CmdSingleFundingComplete return MsgSingleFundingComplete
} }
// MaxPayloadLength returns the maximum allowed payload length for a // MaxPayloadLength returns the maximum allowed payload length for a

@ -1,7 +1,6 @@
package lnwire package lnwire
import ( import (
"fmt"
"io" "io"
"github.com/roasbeef/btcd/btcec" "github.com/roasbeef/btcd/btcec"
@ -152,8 +151,8 @@ func (c *SingleFundingRequest) Encode(w io.Writer, pver uint32) error {
// SingleFundingRequest on the wire. // SingleFundingRequest on the wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (c *SingleFundingRequest) Command() uint32 { func (c *SingleFundingRequest) MsgType() MessageType {
return CmdSingleFundingRequest return MsgSingleFundingRequest
} }
// MaxPayloadLength returns the maximum allowed payload length for a // MaxPayloadLength returns the maximum allowed payload length for a

@ -1,7 +1,6 @@
package lnwire package lnwire
import ( import (
"fmt"
"io" "io"
"github.com/roasbeef/btcd/btcec" "github.com/roasbeef/btcd/btcec"
@ -114,12 +113,12 @@ func (c *SingleFundingResponse) Encode(w io.Writer, pver uint32) error {
c.ConfirmationDepth) c.ConfirmationDepth)
} }
// Command returns the uint32 code which uniquely identifies this message as a // MsgType returns the uint32 code which uniquely identifies this message as a
// SingleFundingResponse on the wire. // SingleFundingResponse on the wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (c *SingleFundingResponse) Command() uint32 { func (c *SingleFundingResponse) MsgType() MessageType {
return CmdSingleFundingResponse return MsgSingleFundingResponse
} }
// MaxPayloadLength returns the maximum allowed payload length for a // MaxPayloadLength returns the maximum allowed payload length for a

@ -1,7 +1,6 @@
package lnwire package lnwire
import ( import (
"fmt"
"io" "io"
"github.com/roasbeef/btcd/btcec" "github.com/roasbeef/btcd/btcec"
@ -54,12 +53,12 @@ func (c *SingleFundingSignComplete) Encode(w io.Writer, pver uint32) error {
c.CommitSignature) c.CommitSignature)
} }
// Command returns the uint32 code which uniquely identifies this message as a // MsgType returns the uint32 code which uniquely identifies this message as a
// SingleFundingSignComplete on the wire. // SingleFundingSignComplete on the wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (c *SingleFundingSignComplete) Command() uint32 { func (c *SingleFundingSignComplete) MsgType() MessageType {
return CmdSingleFundingSignComplete return MsgSingleFundingSignComplete
} }
// MaxPayloadLength returns the maximum allowed payload length for a // MaxPayloadLength returns the maximum allowed payload length for a

@ -1,7 +1,6 @@
package lnwire package lnwire
import ( import (
"fmt"
"io" "io"
"github.com/roasbeef/btcutil" "github.com/roasbeef/btcutil"
@ -94,12 +93,12 @@ func (c *UpdateAddHTLC) Encode(w io.Writer, pver uint32) error {
) )
} }
// Command returns the integer uniquely identifying this message type on the // MsgType returns the integer uniquely identifying this message type on the
// wire. // wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (c *UpdateAddHTLC) Command() uint32 { func (c *UpdateAddHTLC) MsgType() MessageType {
return CmdUpdateAddHTLC return MsgUpdateAddHTLC
} }
// MaxPayloadLength returns the maximum allowed payload size for a UpdateAddHTLC // MaxPayloadLength returns the maximum allowed payload size for a UpdateAddHTLC

@ -120,12 +120,12 @@ func (c *UpdateFailHTLC) Encode(w io.Writer, pver uint32) error {
) )
} }
// Command returns the integer uniquely identifying this message type on the // MsgType returns the integer uniquely identifying this message type on the
// wire. // wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (c *UpdateFailHTLC) Command() uint32 { func (c *UpdateFailHTLC) MsgType() MessageType {
return CmdUpdateFailHTLC return MsgUpdateFailHTLC
} }
// MaxPayloadLength returns the maximum allowed payload size for a UpdateFailHTLC // MaxPayloadLength returns the maximum allowed payload size for a UpdateFailHTLC

@ -60,12 +60,12 @@ func (c *UpdateFufillHTLC) Encode(w io.Writer, pver uint32) error {
) )
} }
// Command returns the integer uniquely identifying this message type on the // MsgType returns the integer uniquely identifying this message type on the
// wire. // wire.
// //
// This is part of the lnwire.Message interface. // This is part of the lnwire.Message interface.
func (c *UpdateFufillHTLC) Command() uint32 { func (c *UpdateFufillHTLC) MsgType() MessageType {
return CmdUpdateFufillHTLC return MsgUpdateFufillHTLC
} }
// MaxPayloadLength returns the maximum allowed payload size for a UpdateFufillHTLC // MaxPayloadLength returns the maximum allowed payload size for a UpdateFufillHTLC