Skip to content

Commit e58fa33

Browse files
authored
Merge pull request #2590 from Crypt-iQ/init_message_payload_fix
lnwire: features "maxAllowedSize" fix
2 parents 6440f39 + d09d514 commit e58fa33

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

lnwire/features.go

+8-10
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,14 @@ const (
4949
// maxAllowedSize is a maximum allowed size of feature vector.
5050
//
5151
// NOTE: Within the protocol, the maximum allowed message size is 65535
52-
// bytes. Adding the overhead from the crypto protocol (the 2-byte
53-
// packet length and 16-byte MAC), we arrive at 65569 bytes. Accounting
54-
// for the overhead within the feature message to signal the type of
55-
// the message, that leaves 65567 bytes for the init message itself.
56-
// Next, we reserve 4-bytes to encode the lengths of both the local and
57-
// global feature vectors, so 65563 for the global and local features.
58-
// Knocking off one byte for the sake of the calculation, that leads to
59-
// a max allowed size of 32781 bytes for each feature vector, or 131124
60-
// different features.
61-
maxAllowedSize = 32781
52+
// bytes for all messages. Accounting for the overhead within the feature
53+
// message to signal the type of message, that leaves us with 65533 bytes
54+
// for the init message itself. Next, we reserve 4 bytes to encode the
55+
// lengths of both the local and global feature vectors, so 65529 bytes
56+
// for the local and global features. Knocking off one byte for the sake
57+
// of the calculation, that leads us to 32764 bytes for each feature
58+
// vector, or 131056 different features.
59+
maxAllowedSize = 32764
6260
)
6361

6462
// LocalFeatures is a mapping of known connection-local feature bits to a

lnwire/init_message.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,5 @@ func (msg *Init) MsgType() MessageType {
6363
//
6464
// This is part of the lnwire.Message interface.
6565
func (msg *Init) MaxPayloadLength(uint32) uint32 {
66-
return 2 + maxAllowedSize + 2 + maxAllowedSize
66+
return 2 + 2 + maxAllowedSize + 2 + maxAllowedSize
6767
}

0 commit comments

Comments
 (0)