diff --git a/lnwire/lnwire.go b/lnwire/lnwire.go index 474e8df1..486dffdf 100644 --- a/lnwire/lnwire.go +++ b/lnwire/lnwire.go @@ -169,9 +169,10 @@ func writeElement(w io.Writer, element interface{}) error { return err } case PkScript: - // Make sure it's P2PKH or P2SH size or less. + // The largest script we'll accept is a p2wsh which is exactly + // 34 bytes long. scriptLength := len(e) - if scriptLength > 25 { + if scriptLength > 34 { return fmt.Errorf("'PkScript' too long") } @@ -425,7 +426,7 @@ func readElement(r io.Reader, element interface{}) error { return err } case *PkScript: - pkScript, err := wire.ReadVarBytes(r, 0, 25, "pkscript") + pkScript, err := wire.ReadVarBytes(r, 0, 34, "pkscript") if err != nil { return err } diff --git a/lnwire/node_announcement.go b/lnwire/node_announcement.go index 82a21b01..47a8c35b 100644 --- a/lnwire/node_announcement.go +++ b/lnwire/node_announcement.go @@ -153,20 +153,7 @@ func (a *NodeAnnouncement) MsgType() MessageType { // // This is part of the lnwire.Message interface. func (a *NodeAnnouncement) MaxPayloadLength(pver uint32) uint32 { - // Signature - 64 bytes - // Timestamp - 4 bytes - // NodeID - 33 bytes - // RGBColor - 3 bytes - // Alias - 32 bytes - // Features - variable - // NumAddresses - 2 bytes - // AddressDescriptor - 1 byte - // Ipv4 - 4 bytes (optional) - // Ipv6 - 16 bytes (optional) - // Port - 2 bytes (optional) - - // Base size, 140, but can be variable due to multiple addresses - return 8192 + return 65533 } // DataToSign returns the part of the message that should be signed. diff --git a/lnwire/single_funding_request.go b/lnwire/single_funding_request.go index 82e54de9..c7468469 100644 --- a/lnwire/single_funding_request.go +++ b/lnwire/single_funding_request.go @@ -147,7 +147,7 @@ func (c *SingleFundingRequest) Encode(w io.Writer, pver uint32) error { 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 // SingleFundingRequest on the wire. // // This is part of the lnwire.Message interface. @@ -191,8 +191,8 @@ func (c *SingleFundingRequest) MaxPayloadLength(uint32) uint32 { // ChannelDerivationPoint - 33 bytes length += 33 - // DeliveryPkScript - 25 bytes - length += 25 + // DeliveryPkScript - 34 bytes + 1 byte varInt + length += 35 // DustLimit - 8 bytes length += 8 diff --git a/lnwire/single_funding_response.go b/lnwire/single_funding_response.go index 0f91f835..5643fe78 100644 --- a/lnwire/single_funding_response.go +++ b/lnwire/single_funding_response.go @@ -145,8 +145,8 @@ func (c *SingleFundingResponse) MaxPayloadLength(uint32) uint32 { // CsvDelay - 4 bytes length += 4 - // DeliveryPkScript - 25 bytes - length += 25 + // DeliveryPkScript - 34 bytes + 1 varInt + length += 35 // DustLimit - 8 bytes length += 8