@@ -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 ;
@@ -117,7 +116,7 @@ pub fn fail_blinded_htlc_backwards(
117116 match i {
118117 0 => {
119118 let mut payment_failed_conditions = PaymentFailedConditions :: new ( )
120- . expected_htlc_error_data ( INVALID_ONION_BLINDING , & [ 0 ; 32 ] ) ;
119+ . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionBlinding , & [ 0 ; 32 ] ) ;
121120 if retry_expected {
122121 payment_failed_conditions = payment_failed_conditions. retry_expected ( ) ;
123122 }
@@ -136,7 +135,7 @@ pub fn fail_blinded_htlc_backwards(
136135 assert_eq ! ( blinded_node_updates. update_fail_malformed_htlcs. len( ) , 1 ) ;
137136 let update_malformed = & blinded_node_updates. update_fail_malformed_htlcs [ 0 ] ;
138137 assert_eq ! ( update_malformed. sha256_of_onion, [ 0 ; 32 ] ) ;
139- assert_eq ! ( update_malformed. failure_code, INVALID_ONION_BLINDING ) ;
138+ assert_eq ! ( update_malformed. failure_code, LocalHTLCFailureReason :: InvalidOnionBlinding . failure_code ( ) ) ;
140139 nodes[ i-1 ] . node . handle_update_fail_malformed_htlc ( nodes[ i] . node . get_our_node_id ( ) , update_malformed) ;
141140 do_commitment_signed_dance ( & nodes[ i-1 ] , & nodes[ i] , & blinded_node_updates. commitment_signed , true , false ) ;
142141 }
@@ -436,11 +435,11 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
436435 match check {
437436 ForwardCheckFail :: ForwardPayloadEncodedAsReceive => {
438437 expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, false ,
439- PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( 0x4000 | 22 , & [ 0 ; 0 ] ) ) ;
438+ PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionPayload , & [ 0 ; 0 ] ) ) ;
440439 }
441440 _ => {
442441 expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, false ,
443- PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( INVALID_ONION_BLINDING , & [ 0 ; 32 ] ) ) ;
442+ PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionBlinding , & [ 0 ; 32 ] ) ) ;
444443 }
445444 } ;
446445 return
@@ -468,20 +467,20 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
468467
469468 let mut updates = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
470469 let update_malformed = & mut updates. update_fail_malformed_htlcs [ 0 ] ;
471- assert_eq ! ( update_malformed. failure_code, INVALID_ONION_BLINDING ) ;
470+ assert_eq ! ( update_malformed. failure_code, LocalHTLCFailureReason :: InvalidOnionBlinding . failure_code ( ) ) ;
472471 assert_eq ! ( update_malformed. sha256_of_onion, [ 0 ; 32 ] ) ;
473472
474473 // Ensure the intro node will properly blind the error if its downstream node failed to do so.
475474 update_malformed. sha256_of_onion = [ 1 ; 32 ] ;
476- update_malformed. failure_code = INVALID_ONION_BLINDING ^ 1 ;
475+ update_malformed. failure_code = LocalHTLCFailureReason :: InvalidOnionBlinding . failure_code ( ) ^ 1 ;
477476 nodes[ 1 ] . node . handle_update_fail_malformed_htlc ( nodes[ 2 ] . node . get_our_node_id ( ) , update_malformed) ;
478477 do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 2 ] , & updates. commitment_signed , true , false ) ;
479478
480479 let mut updates = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
481480 nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
482481 do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates. commitment_signed , false , false ) ;
483482 expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, false ,
484- PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( INVALID_ONION_BLINDING , & [ 0 ; 32 ] ) ) ;
483+ PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionBlinding , & [ 0 ; 32 ] ) ) ;
485484}
486485
487486#[ test]
@@ -533,7 +532,7 @@ fn failed_backwards_to_intro_node() {
533532 let mut updates = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
534533 let mut update_malformed = & mut updates. update_fail_malformed_htlcs [ 0 ] ;
535534 // Check that the final node encodes its failure correctly.
536- assert_eq ! ( update_malformed. failure_code, INVALID_ONION_BLINDING ) ;
535+ assert_eq ! ( update_malformed. failure_code, LocalHTLCFailureReason :: InvalidOnionBlinding . failure_code ( ) ) ;
537536 assert_eq ! ( update_malformed. sha256_of_onion, [ 0 ; 32 ] ) ;
538537
539538 // Modify such the final hop does not correctly blind their error so we can ensure the intro node
@@ -546,7 +545,7 @@ fn failed_backwards_to_intro_node() {
546545 nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
547546 do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates. commitment_signed , false , false ) ;
548547 expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, false ,
549- PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( INVALID_ONION_BLINDING , & [ 0 ; 32 ] ) ) ;
548+ PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionBlinding , & [ 0 ; 32 ] ) ) ;
550549}
551550
552551enum ProcessPendingHTLCsCheck {
@@ -654,20 +653,20 @@ fn do_forward_fail_in_process_pending_htlc_fwds(check: ProcessPendingHTLCsCheck,
654653
655654 let mut updates = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
656655 let update_malformed = & mut updates. update_fail_malformed_htlcs [ 0 ] ;
657- assert_eq ! ( update_malformed. failure_code, INVALID_ONION_BLINDING ) ;
656+ assert_eq ! ( update_malformed. failure_code, LocalHTLCFailureReason :: InvalidOnionBlinding . failure_code ( ) ) ;
658657 assert_eq ! ( update_malformed. sha256_of_onion, [ 0 ; 32 ] ) ;
659658
660659 // Ensure the intro node will properly blind the error if its downstream node failed to do so.
661660 update_malformed. sha256_of_onion = [ 1 ; 32 ] ;
662- update_malformed. failure_code = INVALID_ONION_BLINDING ^ 1 ;
661+ update_malformed. failure_code = LocalHTLCFailureReason :: InvalidOnionBlinding . failure_code ( ) ^ 1 ;
663662 nodes[ 1 ] . node . handle_update_fail_malformed_htlc ( nodes[ 2 ] . node . get_our_node_id ( ) , update_malformed) ;
664663 do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 2 ] , & updates. commitment_signed , true , false ) ;
665664
666665 let mut updates = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
667666 nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
668667 do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates. commitment_signed , false , false ) ;
669668 expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, false ,
670- PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( INVALID_ONION_BLINDING , & [ 0 ; 32 ] ) ) ;
669+ PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionBlinding , & [ 0 ; 32 ] ) ) ;
671670}
672671
673672#[ test]
@@ -1041,7 +1040,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
10411040 assert_eq ! ( updates_2_1. update_fail_malformed_htlcs. len( ) , 1 ) ;
10421041 let update_malformed = & updates_2_1. update_fail_malformed_htlcs [ 0 ] ;
10431042 assert_eq ! ( update_malformed. sha256_of_onion, [ 0 ; 32 ] ) ;
1044- assert_eq ! ( update_malformed. failure_code, INVALID_ONION_BLINDING ) ;
1043+ assert_eq ! ( update_malformed. failure_code, LocalHTLCFailureReason :: InvalidOnionBlinding . failure_code ( ) ) ;
10451044 nodes[ 1 ] . node . handle_update_fail_malformed_htlc ( nodes[ 2 ] . node . get_our_node_id ( ) , update_malformed) ;
10461045 do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 2 ] , & updates_2_1. commitment_signed , true , false ) ;
10471046
@@ -1063,7 +1062,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
10631062 nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates_1_0. update_fail_htlcs [ 0 ] ) ;
10641063 do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates_1_0. commitment_signed , false , false ) ;
10651064 expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, false ,
1066- PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( INVALID_ONION_BLINDING , & [ 0 ; 32 ] ) ) ;
1065+ PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionBlinding , & [ 0 ; 32 ] ) ) ;
10671066}
10681067
10691068#[ test]
@@ -1130,7 +1129,7 @@ fn blinded_path_retries() {
11301129 assert_eq!( updates. update_fail_malformed_htlcs. len( ) , 1 ) ;
11311130 let update_malformed = & updates. update_fail_malformed_htlcs[ 0 ] ;
11321131 assert_eq!( update_malformed. sha256_of_onion, [ 0 ; 32 ] ) ;
1133- assert_eq!( update_malformed. failure_code, INVALID_ONION_BLINDING ) ;
1132+ assert_eq!( update_malformed. failure_code, LocalHTLCFailureReason :: InvalidOnionBlinding . failure_code ( ) ) ;
11341133 $intro_node. node. handle_update_fail_malformed_htlc( nodes[ 3 ] . node. get_our_node_id( ) , update_malformed) ;
11351134 do_commitment_signed_dance( & $intro_node, & nodes[ 3 ] , & updates. commitment_signed, true , false ) ;
11361135
@@ -1250,7 +1249,7 @@ fn min_htlc() {
12501249 nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
12511250 do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates. commitment_signed , false , false ) ;
12521251 expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, false ,
1253- PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( INVALID_ONION_BLINDING , & [ 0 ; 32 ] ) ) ;
1252+ PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionBlinding , & [ 0 ; 32 ] ) ) ;
12541253}
12551254
12561255#[ test]
@@ -1445,7 +1444,7 @@ fn fails_receive_tlvs_authentication() {
14451444 commitment_signed_dance ! ( nodes[ 0 ] , nodes[ 1 ] , update_fail. commitment_signed, false ) ;
14461445 expect_payment_failed_conditions (
14471446 & nodes[ 0 ] , payment_hash, true ,
1448- PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( 0x4000 | 22 , & [ ] ) ,
1447+ PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionPayload , & [ ] ) ,
14491448 ) ;
14501449}
14511450
@@ -1727,7 +1726,8 @@ fn route_blinding_spec_test_vector() {
17271726 match onion_payment:: decode_incoming_update_add_htlc_onion (
17281727 & eve_update_add, & eve_node_signer, & logger, & secp_ctx
17291728 ) {
1730- Err ( HTLCFailureMsg :: Malformed ( msg) ) => assert_eq ! ( msg. failure_code, INVALID_ONION_BLINDING ) ,
1729+ Err ( ( HTLCFailureMsg :: Malformed ( msg) , _) ) => assert_eq ! ( msg. failure_code,
1730+ LocalHTLCFailureReason :: InvalidOnionBlinding . failure_code( ) ) ,
17311731 _ => panic ! ( "Unexpected error" )
17321732 }
17331733}
0 commit comments