@@ -26,8 +26,7 @@ use crate::ln::inbound_payment::ExpandedKey;
2626use crate :: ln:: msgs;
2727use crate :: ln:: msgs:: { BaseMessageHandler , ChannelMessageHandler , UnsignedGossipMessage , MessageSendEvent } ;
2828use crate :: ln:: onion_payment;
29- use crate :: ln:: onion_utils;
30- use crate :: ln:: onion_utils:: INVALID_ONION_BLINDING ;
29+ use crate :: ln:: onion_utils:: { self , LocalHTLCFailureReason } ;
3130use crate :: ln:: outbound_payment:: { Retry , IDEMPOTENCY_TIMEOUT_TICKS } ;
3231use crate :: offers:: invoice:: UnsignedBolt12Invoice ;
3332use crate :: offers:: nonce:: Nonce ;
@@ -118,7 +117,7 @@ pub fn fail_blinded_htlc_backwards(
118117 match i {
119118 0 => {
120119 let mut payment_failed_conditions = PaymentFailedConditions :: new ( )
121- . expected_htlc_error_data ( INVALID_ONION_BLINDING , & [ 0 ; 32 ] ) ;
120+ . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionBlinding , & [ 0 ; 32 ] ) ;
122121 if retry_expected {
123122 payment_failed_conditions = payment_failed_conditions. retry_expected ( ) ;
124123 }
@@ -137,7 +136,7 @@ pub fn fail_blinded_htlc_backwards(
137136 assert_eq ! ( blinded_node_updates. update_fail_malformed_htlcs. len( ) , 1 ) ;
138137 let update_malformed = & blinded_node_updates. update_fail_malformed_htlcs [ 0 ] ;
139138 assert_eq ! ( update_malformed. sha256_of_onion, [ 0 ; 32 ] ) ;
140- assert_eq ! ( update_malformed. failure_code, INVALID_ONION_BLINDING ) ;
139+ assert_eq ! ( update_malformed. failure_code, LocalHTLCFailureReason :: InvalidOnionBlinding . failure_code ( ) ) ;
141140 nodes[ i-1 ] . node . handle_update_fail_malformed_htlc ( nodes[ i] . node . get_our_node_id ( ) , update_malformed) ;
142141 do_commitment_signed_dance ( & nodes[ i-1 ] , & nodes[ i] , & blinded_node_updates. commitment_signed , true , false ) ;
143142 }
@@ -437,11 +436,11 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
437436 match check {
438437 ForwardCheckFail :: ForwardPayloadEncodedAsReceive => {
439438 expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, false ,
440- PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( 0x4000 | 22 , & [ 0 ; 0 ] ) ) ;
439+ PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionPayload , & [ 0 ; 0 ] ) ) ;
441440 }
442441 _ => {
443442 expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, false ,
444- PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( INVALID_ONION_BLINDING , & [ 0 ; 32 ] ) ) ;
443+ PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionBlinding , & [ 0 ; 32 ] ) ) ;
445444 }
446445 } ;
447446 return
@@ -469,20 +468,20 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
469468
470469 let mut updates = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
471470 let update_malformed = & mut updates. update_fail_malformed_htlcs [ 0 ] ;
472- assert_eq ! ( update_malformed. failure_code, INVALID_ONION_BLINDING ) ;
471+ assert_eq ! ( update_malformed. failure_code, LocalHTLCFailureReason :: InvalidOnionBlinding . failure_code ( ) ) ;
473472 assert_eq ! ( update_malformed. sha256_of_onion, [ 0 ; 32 ] ) ;
474473
475474 // Ensure the intro node will properly blind the error if its downstream node failed to do so.
476475 update_malformed. sha256_of_onion = [ 1 ; 32 ] ;
477- update_malformed. failure_code = INVALID_ONION_BLINDING ^ 1 ;
476+ update_malformed. failure_code = LocalHTLCFailureReason :: InvalidOnionBlinding . failure_code ( ) ^ 1 ;
478477 nodes[ 1 ] . node . handle_update_fail_malformed_htlc ( nodes[ 2 ] . node . get_our_node_id ( ) , update_malformed) ;
479478 do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 2 ] , & updates. commitment_signed , true , false ) ;
480479
481480 let mut updates = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
482481 nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
483482 do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates. commitment_signed , false , false ) ;
484483 expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, false ,
485- PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( INVALID_ONION_BLINDING , & [ 0 ; 32 ] ) ) ;
484+ PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionBlinding , & [ 0 ; 32 ] ) ) ;
486485}
487486
488487#[ test]
@@ -534,7 +533,7 @@ fn failed_backwards_to_intro_node() {
534533 let mut updates = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
535534 let mut update_malformed = & mut updates. update_fail_malformed_htlcs [ 0 ] ;
536535 // Check that the final node encodes its failure correctly.
537- assert_eq ! ( update_malformed. failure_code, INVALID_ONION_BLINDING ) ;
536+ assert_eq ! ( update_malformed. failure_code, LocalHTLCFailureReason :: InvalidOnionBlinding . failure_code ( ) ) ;
538537 assert_eq ! ( update_malformed. sha256_of_onion, [ 0 ; 32 ] ) ;
539538
540539 // Modify such the final hop does not correctly blind their error so we can ensure the intro node
@@ -547,7 +546,7 @@ fn failed_backwards_to_intro_node() {
547546 nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
548547 do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates. commitment_signed , false , false ) ;
549548 expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, false ,
550- PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( INVALID_ONION_BLINDING , & [ 0 ; 32 ] ) ) ;
549+ PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionBlinding , & [ 0 ; 32 ] ) ) ;
551550}
552551
553552enum ProcessPendingHTLCsCheck {
@@ -655,20 +654,20 @@ fn do_forward_fail_in_process_pending_htlc_fwds(check: ProcessPendingHTLCsCheck,
655654
656655 let mut updates = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
657656 let update_malformed = & mut updates. update_fail_malformed_htlcs [ 0 ] ;
658- assert_eq ! ( update_malformed. failure_code, INVALID_ONION_BLINDING ) ;
657+ assert_eq ! ( update_malformed. failure_code, LocalHTLCFailureReason :: InvalidOnionBlinding . failure_code ( ) ) ;
659658 assert_eq ! ( update_malformed. sha256_of_onion, [ 0 ; 32 ] ) ;
660659
661660 // Ensure the intro node will properly blind the error if its downstream node failed to do so.
662661 update_malformed. sha256_of_onion = [ 1 ; 32 ] ;
663- update_malformed. failure_code = INVALID_ONION_BLINDING ^ 1 ;
662+ update_malformed. failure_code = LocalHTLCFailureReason :: InvalidOnionBlinding . failure_code ( ) ^ 1 ;
664663 nodes[ 1 ] . node . handle_update_fail_malformed_htlc ( nodes[ 2 ] . node . get_our_node_id ( ) , update_malformed) ;
665664 do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 2 ] , & updates. commitment_signed , true , false ) ;
666665
667666 let mut updates = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
668667 nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
669668 do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates. commitment_signed , false , false ) ;
670669 expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, false ,
671- PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( INVALID_ONION_BLINDING , & [ 0 ; 32 ] ) ) ;
670+ PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionBlinding , & [ 0 ; 32 ] ) ) ;
672671}
673672
674673#[ test]
@@ -1042,7 +1041,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
10421041 assert_eq ! ( updates_2_1. update_fail_malformed_htlcs. len( ) , 1 ) ;
10431042 let update_malformed = & updates_2_1. update_fail_malformed_htlcs [ 0 ] ;
10441043 assert_eq ! ( update_malformed. sha256_of_onion, [ 0 ; 32 ] ) ;
1045- assert_eq ! ( update_malformed. failure_code, INVALID_ONION_BLINDING ) ;
1044+ assert_eq ! ( update_malformed. failure_code, LocalHTLCFailureReason :: InvalidOnionBlinding . failure_code ( ) ) ;
10461045 nodes[ 1 ] . node . handle_update_fail_malformed_htlc ( nodes[ 2 ] . node . get_our_node_id ( ) , update_malformed) ;
10471046 do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 2 ] , & updates_2_1. commitment_signed , true , false ) ;
10481047
@@ -1064,7 +1063,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
10641063 nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates_1_0. update_fail_htlcs [ 0 ] ) ;
10651064 do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates_1_0. commitment_signed , false , false ) ;
10661065 expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, false ,
1067- PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( INVALID_ONION_BLINDING , & [ 0 ; 32 ] ) ) ;
1066+ PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionBlinding , & [ 0 ; 32 ] ) ) ;
10681067}
10691068
10701069#[ test]
@@ -1131,7 +1130,7 @@ fn blinded_path_retries() {
11311130 assert_eq!( updates. update_fail_malformed_htlcs. len( ) , 1 ) ;
11321131 let update_malformed = & updates. update_fail_malformed_htlcs[ 0 ] ;
11331132 assert_eq!( update_malformed. sha256_of_onion, [ 0 ; 32 ] ) ;
1134- assert_eq!( update_malformed. failure_code, INVALID_ONION_BLINDING ) ;
1133+ assert_eq!( update_malformed. failure_code, LocalHTLCFailureReason :: InvalidOnionBlinding . failure_code ( ) ) ;
11351134 $intro_node. node. handle_update_fail_malformed_htlc( nodes[ 3 ] . node. get_our_node_id( ) , update_malformed) ;
11361135 do_commitment_signed_dance( & $intro_node, & nodes[ 3 ] , & updates. commitment_signed, true , false ) ;
11371136
@@ -1251,7 +1250,7 @@ fn min_htlc() {
12511250 nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
12521251 do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates. commitment_signed , false , false ) ;
12531252 expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, false ,
1254- PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( INVALID_ONION_BLINDING , & [ 0 ; 32 ] ) ) ;
1253+ PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionBlinding , & [ 0 ; 32 ] ) ) ;
12551254}
12561255
12571256#[ test]
@@ -1446,7 +1445,7 @@ fn fails_receive_tlvs_authentication() {
14461445 commitment_signed_dance ! ( nodes[ 0 ] , nodes[ 1 ] , update_fail. commitment_signed, false ) ;
14471446 expect_payment_failed_conditions (
14481447 & nodes[ 0 ] , payment_hash, true ,
1449- PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( 0x4000 | 22 , & [ ] ) ,
1448+ PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionPayload , & [ ] ) ,
14501449 ) ;
14511450}
14521451
@@ -1728,7 +1727,8 @@ fn route_blinding_spec_test_vector() {
17281727 match onion_payment:: decode_incoming_update_add_htlc_onion (
17291728 & eve_update_add, & eve_node_signer, & logger, & secp_ctx
17301729 ) {
1731- Err ( HTLCFailureMsg :: Malformed ( msg) ) => assert_eq ! ( msg. failure_code, INVALID_ONION_BLINDING ) ,
1730+ Err ( ( HTLCFailureMsg :: Malformed ( msg) , _) ) => assert_eq ! ( msg. failure_code,
1731+ LocalHTLCFailureReason :: InvalidOnionBlinding . failure_code( ) ) ,
17321732 _ => panic ! ( "Unexpected error" )
17331733 }
17341734}
@@ -2160,7 +2160,7 @@ fn do_test_trampoline_single_hop_receive(success: bool) {
21602160 }
21612161 {
21622162 let payment_failed_conditions = PaymentFailedConditions :: new ( )
2163- . expected_htlc_error_data ( 0x4000 | 22 , & [ 0 ; 0 ] ) ;
2163+ . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionPayload , & [ 0 ; 0 ] ) ;
21642164 expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, true , payment_failed_conditions) ;
21652165 }
21662166 }
@@ -2453,10 +2453,9 @@ fn test_trampoline_forward_rejection() {
24532453 do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & unblinded_node_updates. commitment_signed , false , false ) ;
24542454 }
24552455 {
2456- // Expect a PERM|10 (unknown_next_peer) error while we are unable to route forwarding
2457- // Trampoline payments.
2456+ // Expect UnknownNextPeer error while we are unable to route forwarding Trampoline payments.
24582457 let payment_failed_conditions = PaymentFailedConditions :: new ( )
2459- . expected_htlc_error_data ( 0x4000 | 10 , & [ 0 ; 0 ] ) ;
2458+ . expected_htlc_error_data ( LocalHTLCFailureReason :: UnknownNextPeer , & [ 0 ; 0 ] ) ;
24602459 expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, false , payment_failed_conditions) ;
24612460 }
24622461}
0 commit comments