lnwire: allow overriding of protocol messages outside of custom range

Add the ability to specify messages < CustomRangeStart that will still
be treated like custom messages by lnd (rather than unknown ones). This
allows code external to lnd to handle protocol messages that are *not
yet known to lnd*.
This commit is contained in:
Carla Kirk-Cohen
2022-12-12 10:13:10 -05:00
parent 610f5d2140
commit 93dcbd7ea3
2 changed files with 65 additions and 5 deletions

View File

@@ -237,9 +237,16 @@ func makeEmptyMessage(msgType MessageType) (Message, error) {
case MsgGossipTimestampRange:
msg = &GossipTimestampRange{}
default:
if msgType < CustomTypeStart {
// If the message is not within our custom range and has not
// specifically been overridden, return an unknown message.
//
// Note that we do not allow custom message overrides to replace
// known message types, only protocol messages that are not yet
// known to lnd.
if msgType < CustomTypeStart && !IsCustomOverride(msgType) {
return nil, &UnknownMessage{msgType}
}
msg = &Custom{
Type: msgType,
}