Skip to content

Commit c4c7723

Browse files
toadlyBroodlerustyrussell
authored andcommitted
BOLT 4: seperate out returning errors requirements, copy edit changes
1 parent 91fbda6 commit c4c7723

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

04-onion-routing.md

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ The processing node:
469469
- if the processing node does not have a peer with the matching address:
470470
- MUST drop the packet.
471471
- MUST signal a route failure.
472+
472473
# Shared Secret
473474

474475
The origin node performs ECDH with each hop of the route, in order to establish a secret.
@@ -593,11 +594,6 @@ Where `hmac` is an HMAC authenticating the remainder of the packet, with a key
593594
generated using the above process, with key type `um`, `failuremsg` as defined
594595
below, and `pad` as the extra bytes used to conceal length.
595596

596-
The erring node:
597-
- SHOULD set `pad` such that the `failure_len` plus `pad_len` is equal to 256.
598-
- Note: this value is 118 bytes longer than the longest currently-defined
599-
message.
600-
601597
The erring node then generates a new key, using the key type `ammag`.
602598
This key is then used to generate a pseudo-random stream, which is in turn
603599
applied to the packet using `XOR`.
@@ -618,22 +614,29 @@ key, and computes the HMAC, using each hop's `um` key.
618614
The origin node can detect the sender of the error message by matching the
619615
`hmac` field with the computed HMAC.
620616

621-
The origin node:
617+
The association between the forward and return packets is handled outside of
618+
this onion routing protocol, e.g. via association with an HTLC in a payment
619+
channel.
620+
621+
### Requirements
622+
623+
The _erring node_:
624+
- SHOULD set `pad` such that the `failure_len` plus `pad_len` is equal to 256.
625+
- Note: this value is 118 bytes longer than the longest currently-defined
626+
message.
627+
628+
The _origin node_:
622629
- once the return message has been decrypted:
623630
- SHOULD store a copy of the message.
624631
- SHOULD continue decrypting, until the loop has been repeated 20 times.
625632
- SHOULD use constant `ammag` and `um` keys to obfuscate the route length.
626633

627-
The association between the forward and return packets is handled outside of
628-
this onion routing protocol, e.g. via association with an HTLC in a payment
629-
channel.
630-
631634
## Failure Messages
632635

633636
The failure message encapsulated in `failuremsg` has an identical format as
634637
a normal message: a 2-byte type `failure_code` followed by data applicable
635-
to that type. Following is a list of the currently supported `failure_code`
636-
values and their required use cases.
638+
to that type. Below is a list of the currently supported `failure_code`
639+
values, followed by their use case requirements.
637640

638641
Notice that the `failure_code`s are not of the same type as other message types,
639642
defined in other BOLTs, as they are not sent directly on the transport layer
@@ -730,7 +733,7 @@ An _erring node_:
730733
- MUST select one of the above error codes when creating an error message.
731734
- MUST include the appropriate data for that particular error type.
732735
- if there is more than one error:
733-
- SHOULD select the first error it encounters in list above.
736+
- SHOULD select the first error it encounters from list above.
734737

735738
Any _erring node_ MAY:
736739
- if the `realm` byte is unknown:
@@ -749,16 +752,16 @@ A _forwarding node_ MAY, but a _final node_ MUST NOT:
749752
- if the onion HMAC is incorrect:
750753
- return an `invalid_onion_hmac` error.
751754
- if the ephemeral key in the onion is unparsable:
752-
- return `invalid_onion_key` error.
753-
- if an otherwise unspecified, transient error occurs in the outgoing channel
754-
(i.e. during forwarding to its receiving peer), e.g. channel capacity reached,
755-
too many in-flight HTLCs, etc.:
755+
- return an `invalid_onion_key` error.
756+
- if, during forwarding to its receiving peer, an otherwise unspecified,
757+
transient error occurs in the outgoing channel (e.g. channel capacity reached,
758+
too many in-flight HTLCs, etc.):
756759
- return a `temporary_channel_failure` error.
757760
- if an otherwise unspecified, permanent error occurs during forwarding to its
758761
receiving peer (e.g. channel recently closed):
759762
- return a `permanent_channel_failure` error.
760763
- if the outgoing channel has requirements advertised in its
761-
`channel_announcement` `features`, which were NOT included in the onion:
764+
`channel_announcement`'s `features`, which were NOT included in the onion:
762765
- return a `required_channel_feature_missing` error.
763766
- if the receiving peer specified by the onion is NOT known:
764767
- return an `unknown_next_peer` error.
@@ -768,20 +771,20 @@ A _forwarding node_ MAY, but a _final node_ MUST NOT:
768771
- return an `amount_below_minimum` error.
769772
- if the HTLC does NOT pay a sufficient fee:
770773
- report the amount of the incoming HTLC and the current channel setting for
771-
the outgoing channel:
774+
the outgoing channel.
772775
- return a `fee_insufficient` error.
773776
- if the `outgoing_cltv_value` does NOT match the `update_add_htlc`'s
774777
`cltv_expiry` minus the `cltv_expiry_delta` for the outgoing channel:
775778
- report the `cltv_expiry` and the current channel setting for the outgoing
776779
channel.
777780
- return an `incorrect_cltv_expiry` error.
778-
- if the `cltv_expiry` is too near:
781+
- if the `cltv_expiry` is unreasonably near the present:
779782
- report the current channel setting for the outgoing channel.
780783
- return an `expiry_too_soon` error.
781784
- if the `cltv_expiry` is unreasonably far in the future:
782785
- return an `expiry_too_far` error.
783786
- if the channel is disabled:
784-
- report the current channel setting for the outgoing channel:
787+
- report the current channel setting for the outgoing channel.
785788
- return a `channel_disabled` error.
786789

787790
An _intermediate hop_ MUST NOT, but the _final node_:
@@ -796,9 +799,9 @@ An _intermediate hop_ MUST NOT, but the _final node_:
796799
- if the amount paid is more than twice the amount expected:
797800
- SHOULD fail the HTLC.
798801
- SHOULD return an `incorrect_payment_amount` error.
799-
- Note: this allows the origin node to reduce information leakage by
800-
altering the amount while not allowing for accidental gross overpayment.
801-
- if the `cltv_expiry` value is too near the present:
802+
- Note: this allows the origin node to reduce information leakage by
803+
altering the amount while not allowing for accidental gross overpayment.
804+
- if the `cltv_expiry` value is unreasonably near the present:
802805
- MUST fail the HTLC.
803806
- MUST return a `final_expiry_too_soon` error.
804807
- if the `outgoing_cltv_value` does NOT correspond with the `cltv_expiry` from
@@ -810,6 +813,8 @@ An _intermediate hop_ MUST NOT, but the _final node_:
810813

811814
## Receiving Failure Codes
812815

816+
### Requirements
817+
813818
The _origin node_:
814819
- MUST ignore any extra bytes in `failuremsg`.
815820
- if the _final node_ is returning the error:

0 commit comments

Comments
 (0)