| | | 1 | | namespace NLightning.Domain.Protocol.Messages; |
| | | 2 | | |
| | | 3 | | using Constants; |
| | | 4 | | using Models; |
| | | 5 | | using Payloads; |
| | | 6 | | using Tlv; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Represents an init message. |
| | | 10 | | /// </summary> |
| | | 11 | | /// <remarks> |
| | | 12 | | /// The init message is used to communicate the features of the node. |
| | | 13 | | /// The message type is 16. |
| | | 14 | | /// </remarks> |
| | | 15 | | public sealed class InitMessage : BaseMessage |
| | | 16 | | { |
| | | 17 | | /// <summary> |
| | | 18 | | /// The payload of the message. |
| | | 19 | | /// </summary> |
| | 8 | 20 | | public new InitPayload Payload { get => (InitPayload)base.Payload; } |
| | | 21 | | |
| | 0 | 22 | | public NetworksTlv? NetworksTlv { get; } |
| | | 23 | | |
| | 0 | 24 | | public RemoteAddressTlv? RemoteAddressTlv { get; } |
| | | 25 | | |
| | | 26 | | public InitMessage(InitPayload payload, NetworksTlv? networksTlv = null, RemoteAddressTlv? remoteAddressTlv = null) |
| | 16 | 27 | | : base(MessageTypes.Init, payload) |
| | | 28 | | { |
| | 16 | 29 | | NetworksTlv = networksTlv; |
| | 16 | 30 | | RemoteAddressTlv = remoteAddressTlv; |
| | | 31 | | |
| | 16 | 32 | | if (networksTlv is not null || remoteAddressTlv is not null) |
| | | 33 | | { |
| | 8 | 34 | | Extension = new TlvStream(); |
| | 8 | 35 | | Extension.Add(networksTlv, remoteAddressTlv); |
| | | 36 | | } |
| | 16 | 37 | | } |
| | | 38 | | } |