lnwire: add new closing_complete and closing_sig messages

These two messages will be used to implement the new and improved co-op
closing protocol. This PR also show cases how to use the new
`tlv.OptionalRecord` type to define and handle TLV level parsing.

I think we can make one additional helper function to clean up some of
the boiler plate for the encode/decode.
This commit is contained in:
Olaoluwa Osuntokun
2024-01-02 18:45:39 -08:00
parent 34fd35bc63
commit 3d88017b38
4 changed files with 356 additions and 0 deletions

View File

@@ -34,6 +34,8 @@ const (
MsgChannelReady = 36
MsgShutdown = 38
MsgClosingSigned = 39
MsgClosingComplete = 40
MsgClosingSig = 41
MsgDynPropose = 111
MsgDynAck = 113
MsgDynReject = 115
@@ -146,6 +148,10 @@ func (t MessageType) String() string {
return "ReplyChannelRange"
case MsgGossipTimestampRange:
return "GossipTimestampRange"
case MsgClosingComplete:
return "ClosingComplete"
case MsgClosingSig:
return "ClosingSig"
default:
return "<unknown>"
}
@@ -256,6 +262,10 @@ func makeEmptyMessage(msgType MessageType) (Message, error) {
msg = &ReplyChannelRange{}
case MsgGossipTimestampRange:
msg = &GossipTimestampRange{}
case MsgClosingComplete:
msg = &ClosingComplete{}
case MsgClosingSig:
msg = &ClosingSig{}
default:
// If the message is not within our custom range and has not
// specifically been overridden, return an unknown message.