From 3f3d56a660af08d219224125864bab621a4f4f59 Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Tue, 18 Feb 2020 01:32:50 +0800 Subject: [PATCH 1/7] add "Ligtning Messages" section --- communications_protocol.asciidoc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/communications_protocol.asciidoc b/communications_protocol.asciidoc index e70d448..2cf066d 100644 --- a/communications_protocol.asciidoc +++ b/communications_protocol.asciidoc @@ -13,6 +13,21 @@ If you want to learn more we suggest you check out http://www.noiseprotocol.org/ === Ligtning Messages +Each Ligtning Message contains 2 bytes indicating the *type* of message, and a variable-length *payload*. +A *payload* needs to be interpreted according the *type*. + +A Ligtning Message falls into one of the following groups: + +[cols="3,3,10",options="header"] +|======= +| Group | Type | Description +| Setup & Control | 0~31 | Messages related to connection setup, control, supported features, and error reporting +| Channel | 32~127 | Messages related to setup and close channels +| Commitment | 128~255 | Messages related to updating the current commitment transaction +| Routing | 256~511 | Messages related to node and channel announcements, or active route explorations +| Custom | 32768~65535 | Experimental or custom messages +|======= + === Opening a Payment channel === forwarding, making and receiving a payment From 9f1755a012c47523c25e8641d7a0a2f4787d793f Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Tue, 18 Feb 2020 01:38:10 +0800 Subject: [PATCH 2/7] fix typos --- communications_protocol.asciidoc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/communications_protocol.asciidoc b/communications_protocol.asciidoc index 2cf066d..edd4a8e 100644 --- a/communications_protocol.asciidoc +++ b/communications_protocol.asciidoc @@ -11,12 +11,12 @@ This protocol framework is also used by Whatsapp and Wireguard and is very well If you want to learn more we suggest you check out http://www.noiseprotocol.org/ ==== -=== Ligtning Messages +=== Lightning Messages -Each Ligtning Message contains 2 bytes indicating the *type* of message, and a variable-length *payload*. +Each Lightning Message contains 2 bytes indicating the *type* of message, and a variable-length *payload*. A *payload* needs to be interpreted according the *type*. -A Ligtning Message falls into one of the following groups: +A Lightning Message falls into one of the following groups: [cols="3,3,10",options="header"] |======= From 8df077aa41656f22e83ae2204f0790e613ef930c Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Sat, 22 Feb 2020 16:17:20 +0800 Subject: [PATCH 3/7] format table --- communications_protocol.asciidoc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/communications_protocol.asciidoc b/communications_protocol.asciidoc index edd4a8e..e3fd5a0 100644 --- a/communications_protocol.asciidoc +++ b/communications_protocol.asciidoc @@ -20,12 +20,12 @@ A Lightning Message falls into one of the following groups: [cols="3,3,10",options="header"] |======= -| Group | Type | Description -| Setup & Control | 0~31 | Messages related to connection setup, control, supported features, and error reporting -| Channel | 32~127 | Messages related to setup and close channels -| Commitment | 128~255 | Messages related to updating the current commitment transaction -| Routing | 256~511 | Messages related to node and channel announcements, or active route explorations -| Custom | 32768~65535 | Experimental or custom messages +| Group | Type | Description +| Setup & Control | 0~31 | Messages related to connection setup, control, supported features, and error reporting +| Channel | 32~127 | Messages related to setup and close channels +| Commitment | 128~255 | Messages related to updating the current commitment transaction +| Routing | 256~511 | Messages related to node and channel announcements, or active route explorations +| Custom | 32768~65535 | Experimental or custom messages |======= === Opening a Payment channel From e055541a3a391149d23c8083a5f746c0665f29ac Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Sat, 22 Feb 2020 16:55:50 +0800 Subject: [PATCH 4/7] add "it's OK to be odd" rule --- communications_protocol.asciidoc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/communications_protocol.asciidoc b/communications_protocol.asciidoc index e3fd5a0..ccaf8e1 100644 --- a/communications_protocol.asciidoc +++ b/communications_protocol.asciidoc @@ -28,6 +28,15 @@ A Lightning Message falls into one of the following groups: | Custom | 32768~65535 | Experimental or custom messages |======= +Lightning Messages follows two forethoughtful rules: "it's OK to be odd" rule and "ignore additional data" rule. Both of them allow for future extension of Lightning Messages. + +=== "It's OK to be odd" rule + +Lightning Message type follows the _it's ok to be odd_ rule. A node is allowed to send a message of an _odd_-numbered type, but not _even_-numbered type without prior negotiation. Once a node receives a _oddly_-but-unknown-typed message, it should ignore it. However, if it receives a _evenly_-but-unknown-typed message, it is expected to fail the channels. + +=== "Ignore additional data" rule + + === Opening a Payment channel === forwarding, making and receiving a payment From e2d167c45f2e0f1f06cfa7cca378268915042481 Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Sat, 22 Feb 2020 17:03:27 +0800 Subject: [PATCH 5/7] fix typos --- communications_protocol.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/communications_protocol.asciidoc b/communications_protocol.asciidoc index ccaf8e1..67ee5ab 100644 --- a/communications_protocol.asciidoc +++ b/communications_protocol.asciidoc @@ -32,7 +32,7 @@ Lightning Messages follows two forethoughtful rules: "it's OK to be odd" rule an === "It's OK to be odd" rule -Lightning Message type follows the _it's ok to be odd_ rule. A node is allowed to send a message of an _odd_-numbered type, but not _even_-numbered type without prior negotiation. Once a node receives a _oddly_-but-unknown-typed message, it should ignore it. However, if it receives a _evenly_-but-unknown-typed message, it is expected to fail the channels. +Lightning Message type follows the _it's ok to be odd_ rule. A node is allowed to send a message of an _odd_-numbered type, but not _even_-numbered type without prior negotiation. Once a node receives an _oddly_-but-unknown-typed message, it should ignore it. However, if it receives an _evenly_-but-unknown-typed message, it is expected to fail the channels. === "Ignore additional data" rule From 8db4fe6f1bb7012d03f6d12fd9aa3159a792ad4c Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Sat, 22 Feb 2020 19:45:05 +0800 Subject: [PATCH 6/7] add "ignore additional data" rule --- communications_protocol.asciidoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/communications_protocol.asciidoc b/communications_protocol.asciidoc index 67ee5ab..8c76ddf 100644 --- a/communications_protocol.asciidoc +++ b/communications_protocol.asciidoc @@ -36,6 +36,9 @@ Lightning Message type follows the _it's ok to be odd_ rule. A node is allowed t === "Ignore additional data" rule +The length of a Lightning Message is a 2-byte unsigned int, so the maximum message size is 65535 bytes. + +If a node receives a message with additional data longer than it expects for the corresponding type, the exceeding part will be discarded. On the contrary, if a node receives a message shorter than it expects, it fails the channels. === Opening a Payment channel From 64291052c0344db57a8c978728dde0c23bd7f376 Mon Sep 17 00:00:00 2001 From: HAOYUatHZ Date: Sun, 23 Feb 2020 15:09:13 +0800 Subject: [PATCH 7/7] lower dowm header levels --- communications_protocol.asciidoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/communications_protocol.asciidoc b/communications_protocol.asciidoc index 8c76ddf..caa433e 100644 --- a/communications_protocol.asciidoc +++ b/communications_protocol.asciidoc @@ -30,11 +30,11 @@ A Lightning Message falls into one of the following groups: Lightning Messages follows two forethoughtful rules: "it's OK to be odd" rule and "ignore additional data" rule. Both of them allow for future extension of Lightning Messages. -=== "It's OK to be odd" rule +==== "It's OK to be odd" rule Lightning Message type follows the _it's ok to be odd_ rule. A node is allowed to send a message of an _odd_-numbered type, but not _even_-numbered type without prior negotiation. Once a node receives an _oddly_-but-unknown-typed message, it should ignore it. However, if it receives an _evenly_-but-unknown-typed message, it is expected to fail the channels. -=== "Ignore additional data" rule +==== "Ignore additional data" rule The length of a Lightning Message is a 2-byte unsigned int, so the maximum message size is 65535 bytes.