@@ -633,161 +633,182 @@ channel.
633
633
The failure message encapsulated in ` failuremsg ` has an identical format as
634
634
a normal message: a 2-byte type ` failure_code ` followed by data applicable
635
635
to that type. Following is a list of the currently supported ` failure_code `
636
- values and their associated use cases.
636
+ values and their required use cases.
637
637
638
638
Notice that the ` failure_code ` s are not of the same type as other message types,
639
639
defined in other BOLTs, as they are not sent directly on the transport layer
640
640
but are instead wrapped inside return packets.
641
641
The numeric values for the ` failure_code ` may therefore reuse values, that are
642
642
also assigned to other message types, without any danger of causing collisions.
643
643
644
- An erring node:
645
- - MUST select one of these codes when creating an error message.
646
- - MUST include the appropriate data for that particular error type.
647
- - if there is more than one error:
648
- - SHOULD select the first error it encounters from the list below.
649
-
650
644
The top byte of ` failure_code ` can be read as a set of flags:
651
645
* 0x8000 (BADONION): unparsable onion encrypted by sending peer
652
646
* 0x4000 (PERM): permanent failure (otherwise transient)
653
647
* 0x2000 (NODE): node failure (otherwise channel)
654
648
* 0x1000 (UPDATE): new channel update enclosed
655
649
656
- Any _ erring node_ MAY return one of the following errors:
657
-
658
- If the ` realm ` byte is unknown:
659
650
1 . type: PERM|1 (` invalid_realm ` )
660
651
661
- If an otherwise unspecified transient error occurs for the entire node:
662
652
1 . type: NODE|2 (` temporary_node_failure ` )
663
653
664
- If an otherwise unspecified permanent error occurs for the entire node:
665
654
1 . type: PERM|NODE|2 (` permanent_node_failure ` )
666
655
667
- If a node has requirements advertised in its ` node_announcement ` ` features `
668
- which were NOT included in the onion:
669
656
1 . type: PERM|NODE|3 (` required_node_feature_missing ` )
670
657
671
- A _ forwarding node_ MAY, but a _ final node_ MUST NOT, return one of the following
672
- errors:
673
-
674
- If the onion ` version ` byte is unknown:
675
658
1 . type: BADONION|PERM|4 (` invalid_onion_version ` )
676
659
2 . data:
677
660
* [ ` 32 ` :` sha256_of_onion ` ]
678
661
679
- If the onion HMAC is incorrect:
680
662
1 . type: BADONION|PERM|5 (` invalid_onion_hmac ` )
681
663
2 . data:
682
664
* [ ` 32 ` :` sha256_of_onion ` ]
683
665
684
- If the ephemeral key in the onion is unparsable:
685
666
1 . type: BADONION|PERM|6 (` invalid_onion_key ` )
686
667
2 . data:
687
668
* [ ` 32 ` :` sha256_of_onion ` ]
688
669
689
- If an otherwise unspecified, transient error occurs in the outgoing channel
690
- (i.e. during forwarding to its receiving peer), e.g. channel capacity reached,
691
- too many in-flight HTLCs, etc.:
692
670
1 . type: UPDATE|7 (` temporary_channel_failure ` )
693
671
2 . data:
694
672
* [ ` 2 ` :` len ` ]
695
673
* [ ` len ` :` channel_update ` ]
696
674
697
- If an otherwise unspecified, permanent error occurs during forwarding to its
698
- receiving peer (e.g. channel recently closed):
699
675
1 . type: PERM|8 (` permanent_channel_failure ` )
700
676
701
- If the outgoing channel has requirements advertised in its
702
- ` channel_announcement ` ` features ` which were NOT included in the onion:
703
677
1 . type: PERM|9 (` required_channel_feature_missing ` )
704
678
705
- If the receiving peer specified by the onion is NOT known:
706
679
1 . type: PERM|10 (` unknown_next_peer ` )
707
680
708
- If the HTLC amount is less than the currently specified minimum amount, the
709
- amount of the incoming HTLC and the current channel setting for the outgoing
710
- channel are reported:
711
681
1 . type: UPDATE|11 (` amount_below_minimum ` )
712
682
2 . data:
713
683
* [ ` 8 ` :` htlc_msat ` ]
714
684
* [ ` 2 ` :` len ` ]
715
685
* [ ` len ` :` channel_update ` ]
716
686
717
- If the HTLC does NOT pay a sufficient fee, the amount of the incoming HTLC and
718
- the current channel setting for the outgoing channel are reported:
719
687
1 . type: UPDATE|12 (` fee_insufficient ` )
720
688
2 . data:
721
689
* [ ` 8 ` :` htlc_msat ` ]
722
690
* [ ` 2 ` :` len ` ]
723
691
* [ ` len ` :` channel_update ` ]
724
692
725
- If the ` outgoing_cltv_value ` does NOT match the ` update_add_htlc ` 's
726
- ` cltv_expiry ` minus the ` cltv_expiry_delta ` for the outgoing channel, the
727
- ` cltv_expiry ` and the current channel setting for the outgoing channel are
728
- reported:
729
693
1 . type: UPDATE|13 (` incorrect_cltv_expiry ` )
730
694
2 . data:
731
695
* [ ` 4 ` :` cltv_expiry ` ]
732
696
* [ ` 2 ` :` len ` ]
733
697
* [ ` len ` :` channel_update ` ]
734
698
735
- If the ` cltv_expiry ` is too near, the current channel setting for the
736
- outgoing channel are reported:
737
699
1 . type: UPDATE|14 (` expiry_too_soon ` )
738
700
2 . data:
739
701
* [ ` 2 ` :` len ` ]
740
702
* [ ` len ` :` channel_update ` ]
741
703
742
- If the ` cltv_expiry ` is unreasonably far in the future, its also possible to
743
- report an error:
744
704
1 . type: 21 (` expiry_too_far ` )
745
705
746
- If the channel is disabled, the current channel setting for the outgoing
747
- channel are reported:
748
706
1 . type: UPDATE|20 (` channel_disabled ` )
749
707
2 . data:
750
708
* [ ` 2 ` : ` flags ` ]
751
709
* [ ` 2 ` :` len ` ]
752
710
* [ ` len ` :` channel_update ` ]
711
+ [ FIXME: is it important that 20 and 21 remain in this order or can they be moved to end of list?]
753
712
754
- The _ final node_ MAY, but an _ intermediate hop_ MUST NOT, return one of the
755
- following errors:
756
- - if the payment hash has already been paid:
757
- - MAY treat the payment hash as unknown.
758
- - MAY succeed in accepting the HTLC.
759
- - if the amount paid is less than the amount expected:
760
- - MUST fail the HTLC.
761
-
762
- If the payment hash is unknown, the _ final node_ MUST fail the HTLC:
763
713
1 . type: PERM|15 (` unknown_payment_hash ` )
764
714
765
- If the amount paid is more than twice the amount expected, the _ final node_
766
- SHOULD fail the HTLC. Note: this allows the origin node to reduce information
767
- leakage by altering the amount while not allowing for accidental gross
768
- overpayment:
769
715
1 . type: PERM|16 (` incorrect_payment_amount ` )
770
716
771
- If the ` cltv_expiry ` value is too near the present, the _ final node_ MUST fail
772
- the HTLC:
773
717
1 . type: 17 (` final_expiry_too_soon ` )
774
718
775
- If the ` outgoing_cltv_value ` does NOT correspond with the ` cltv_expiry ` from
776
- the final node's HTLC:
777
719
1 . type: 18 (` final_incorrect_cltv_expiry ` )
778
720
2 . data:
779
721
* [ ` 4 ` :` cltv_expiry ` ]
780
722
781
- If the ` amt_to_forward ` is greater than the ` incoming_htlc_amt ` from the
782
- final node's HTLC:
783
723
1 . type: 19 (` final_incorrect_htlc_amount ` )
784
724
2 . data:
785
- * [ ` 4 ` :` incoming_htlc_amt ` ]
725
+ * [ ` 4 ` :` incoming_htlc_amt ` ]
786
726
787
- [ TODO: Restore edited text and move the definitions of the structures into its own section, then turn the words describing each one into requirements ]
727
+ ### Requirements
788
728
789
- ## Receiving Failure Codes
729
+ An _ erring node_ :
730
+ - MUST select one of the above error codes when creating an error message.
731
+ - MUST include the appropriate data for that particular error type.
732
+ - if there is more than one error:
733
+ - SHOULD select the first error it encounters in list above.
734
+
735
+ Any _ erring node_ MAY:
736
+ - if the ` realm ` byte is unknown:
737
+ - return an ` invalid_realm ` error.
738
+ - if an otherwise unspecified transient error occurs for the entire node:
739
+ - return a ` temporary_node_failure ` error.
740
+ - if an otherwise unspecified permanent error occurs for the entire node:
741
+ - return a ` permanent_node_failure ` error.
742
+ - if a node has requirements advertised in its ` node_announcement ` ` features ` ,
743
+ which were NOT included in the onion:
744
+ - return a ` required_node_feature_missing ` error.
745
+
746
+ A _ forwarding node_ MAY, but a _ final node_ MUST NOT:
747
+ - if the onion ` version ` byte is unknown:
748
+ - return an ` invalid_onion_version ` error.
749
+ - if the onion HMAC is incorrect:
750
+ - return an ` invalid_onion_hmac ` error.
751
+ - 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.:
756
+ - return a ` temporary_channel_failure ` error.
757
+ - if an otherwise unspecified, permanent error occurs during forwarding to its
758
+ receiving peer (e.g. channel recently closed):
759
+ - return a ` permanent_channel_failure ` error.
760
+ - if the outgoing channel has requirements advertised in its
761
+ ` channel_announcement ` ` features ` , which were NOT included in the onion:
762
+ - return a ` required_channel_feature_missing ` error.
763
+ - if the receiving peer specified by the onion is NOT known:
764
+ - return an ` unknown_next_peer ` error.
765
+ - if the HTLC amount is less than the currently specified minimum amount:
766
+ - report the amount of the incoming HTLC and the current channel setting for
767
+ the outgoing channel.
768
+ - return an ` amount_below_minimum ` error.
769
+ - if the HTLC does NOT pay a sufficient fee:
770
+ - report the amount of the incoming HTLC and the current channel setting for
771
+ the outgoing channel:
772
+ - return a ` fee_insufficient ` error.
773
+ - if the ` outgoing_cltv_value ` does NOT match the ` update_add_htlc ` 's
774
+ ` cltv_expiry ` minus the ` cltv_expiry_delta ` for the outgoing channel:
775
+ - report the ` cltv_expiry ` and the current channel setting for the outgoing
776
+ channel.
777
+ - return an ` incorrect_cltv_expiry ` error.
778
+ - if the ` cltv_expiry ` is too near:
779
+ - report the current channel setting for the outgoing channel.
780
+ - return an ` expiry_too_soon ` error.
781
+ - if the ` cltv_expiry ` is unreasonably far in the future:
782
+ - return an ` expiry_too_far ` error.
783
+ - if the channel is disabled:
784
+ - report the current channel setting for the outgoing channel:
785
+ - return a ` channel_disabled ` error.
786
+
787
+ An _ intermediate hop_ MUST NOT, but the _ final node_ :
788
+ - if the payment hash has already been paid:
789
+ - MAY treat the payment hash as unknown.
790
+ - MAY succeed in accepting the HTLC.
791
+ - if the amount paid is less than the amount expected:
792
+ - MUST fail the HTLC.
793
+ - if the payment hash is unknown:
794
+ - MUST fail the HTLC.
795
+ - MUST return an ` unknown_payment_hash ` error.
796
+ - if the amount paid is more than twice the amount expected:
797
+ - SHOULD fail the HTLC.
798
+ - 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
+ - MUST fail the HTLC.
803
+ - MUST return a ` final_expiry_too_soon ` error.
804
+ - if the ` outgoing_cltv_value ` does NOT correspond with the ` cltv_expiry ` from
805
+ the final node's HTLC:
806
+ - [ FIXME: MAY|SHOULD|MUST?] return ` final_incorrect_cltv_expiry ` error.
807
+ - if the ` amt_to_forward ` is greater than the ` incoming_htlc_amt ` from the
808
+ final node's HTLC:
809
+ - [ FIXME: MAY|SHOULD|MUST?] return a ` final_incorrect_htlc_amount ` error.
790
810
811
+ ## Receiving Failure Codes
791
812
792
813
The _ origin node_ :
793
814
- MUST ignore any extra bytes in ` failuremsg ` .
0 commit comments