@@ -26,8 +26,7 @@ use crate::ln::inbound_payment::ExpandedKey;
26
26
use crate :: ln:: msgs;
27
27
use crate :: ln:: msgs:: { BaseMessageHandler , ChannelMessageHandler , UnsignedGossipMessage , MessageSendEvent } ;
28
28
use 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 } ;
31
30
use crate :: ln:: outbound_payment:: { Retry , IDEMPOTENCY_TIMEOUT_TICKS } ;
32
31
use crate :: offers:: invoice:: UnsignedBolt12Invoice ;
33
32
use crate :: offers:: nonce:: Nonce ;
@@ -117,7 +116,7 @@ pub fn fail_blinded_htlc_backwards(
117
116
match i {
118
117
0 => {
119
118
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 ] ) ;
121
120
if retry_expected {
122
121
payment_failed_conditions = payment_failed_conditions. retry_expected ( ) ;
123
122
}
@@ -136,7 +135,7 @@ pub fn fail_blinded_htlc_backwards(
136
135
assert_eq ! ( blinded_node_updates. update_fail_malformed_htlcs. len( ) , 1 ) ;
137
136
let update_malformed = & blinded_node_updates. update_fail_malformed_htlcs [ 0 ] ;
138
137
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 ( ) ) ;
140
139
nodes[ i-1 ] . node . handle_update_fail_malformed_htlc ( nodes[ i] . node . get_our_node_id ( ) , update_malformed) ;
141
140
do_commitment_signed_dance ( & nodes[ i-1 ] , & nodes[ i] , & blinded_node_updates. commitment_signed , true , false ) ;
142
141
}
@@ -436,11 +435,11 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
436
435
match check {
437
436
ForwardCheckFail :: ForwardPayloadEncodedAsReceive => {
438
437
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 ] ) ) ;
440
439
}
441
440
_ => {
442
441
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 ] ) ) ;
444
443
}
445
444
} ;
446
445
return
@@ -468,20 +467,20 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
468
467
469
468
let mut updates = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
470
469
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 ( ) ) ;
472
471
assert_eq ! ( update_malformed. sha256_of_onion, [ 0 ; 32 ] ) ;
473
472
474
473
// Ensure the intro node will properly blind the error if its downstream node failed to do so.
475
474
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 ;
477
476
nodes[ 1 ] . node . handle_update_fail_malformed_htlc ( nodes[ 2 ] . node . get_our_node_id ( ) , update_malformed) ;
478
477
do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 2 ] , & updates. commitment_signed , true , false ) ;
479
478
480
479
let mut updates = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
481
480
nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
482
481
do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates. commitment_signed , false , false ) ;
483
482
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 ] ) ) ;
485
484
}
486
485
487
486
#[ test]
@@ -533,7 +532,7 @@ fn failed_backwards_to_intro_node() {
533
532
let mut updates = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
534
533
let mut update_malformed = & mut updates. update_fail_malformed_htlcs [ 0 ] ;
535
534
// 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 ( ) ) ;
537
536
assert_eq ! ( update_malformed. sha256_of_onion, [ 0 ; 32 ] ) ;
538
537
539
538
// 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() {
546
545
nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
547
546
do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates. commitment_signed , false , false ) ;
548
547
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 ] ) ) ;
550
549
}
551
550
552
551
enum ProcessPendingHTLCsCheck {
@@ -654,20 +653,20 @@ fn do_forward_fail_in_process_pending_htlc_fwds(check: ProcessPendingHTLCsCheck,
654
653
655
654
let mut updates = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
656
655
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 ( ) ) ;
658
657
assert_eq ! ( update_malformed. sha256_of_onion, [ 0 ; 32 ] ) ;
659
658
660
659
// Ensure the intro node will properly blind the error if its downstream node failed to do so.
661
660
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 ;
663
662
nodes[ 1 ] . node . handle_update_fail_malformed_htlc ( nodes[ 2 ] . node . get_our_node_id ( ) , update_malformed) ;
664
663
do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 2 ] , & updates. commitment_signed , true , false ) ;
665
664
666
665
let mut updates = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
667
666
nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
668
667
do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates. commitment_signed , false , false ) ;
669
668
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 ] ) ) ;
671
670
}
672
671
673
672
#[ test]
@@ -1041,7 +1040,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
1041
1040
assert_eq ! ( updates_2_1. update_fail_malformed_htlcs. len( ) , 1 ) ;
1042
1041
let update_malformed = & updates_2_1. update_fail_malformed_htlcs [ 0 ] ;
1043
1042
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 ( ) ) ;
1045
1044
nodes[ 1 ] . node . handle_update_fail_malformed_htlc ( nodes[ 2 ] . node . get_our_node_id ( ) , update_malformed) ;
1046
1045
do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 2 ] , & updates_2_1. commitment_signed , true , false ) ;
1047
1046
@@ -1063,7 +1062,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
1063
1062
nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates_1_0. update_fail_htlcs [ 0 ] ) ;
1064
1063
do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates_1_0. commitment_signed , false , false ) ;
1065
1064
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 ] ) ) ;
1067
1066
}
1068
1067
1069
1068
#[ test]
@@ -1130,7 +1129,7 @@ fn blinded_path_retries() {
1130
1129
assert_eq!( updates. update_fail_malformed_htlcs. len( ) , 1 ) ;
1131
1130
let update_malformed = & updates. update_fail_malformed_htlcs[ 0 ] ;
1132
1131
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 ( ) ) ;
1134
1133
$intro_node. node. handle_update_fail_malformed_htlc( nodes[ 3 ] . node. get_our_node_id( ) , update_malformed) ;
1135
1134
do_commitment_signed_dance( & $intro_node, & nodes[ 3 ] , & updates. commitment_signed, true , false ) ;
1136
1135
@@ -1250,7 +1249,7 @@ fn min_htlc() {
1250
1249
nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
1251
1250
do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates. commitment_signed , false , false ) ;
1252
1251
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 ] ) ) ;
1254
1253
}
1255
1254
1256
1255
#[ test]
@@ -1445,7 +1444,7 @@ fn fails_receive_tlvs_authentication() {
1445
1444
commitment_signed_dance ! ( nodes[ 0 ] , nodes[ 1 ] , update_fail. commitment_signed, false ) ;
1446
1445
expect_payment_failed_conditions (
1447
1446
& nodes[ 0 ] , payment_hash, true ,
1448
- PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( 0x4000 | 22 , & [ ] ) ,
1447
+ PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionPayload , & [ ] ) ,
1449
1448
) ;
1450
1449
}
1451
1450
@@ -1727,7 +1726,8 @@ fn route_blinding_spec_test_vector() {
1727
1726
match onion_payment:: decode_incoming_update_add_htlc_onion (
1728
1727
& eve_update_add, & eve_node_signer, & logger, & secp_ctx
1729
1728
) {
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( ) ) ,
1731
1731
_ => panic ! ( "Unexpected error" )
1732
1732
}
1733
1733
}
0 commit comments