@@ -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 ;
@@ -118,7 +117,7 @@ pub fn fail_blinded_htlc_backwards(
118
117
match i {
119
118
0 => {
120
119
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 ] ) ;
122
121
if retry_expected {
123
122
payment_failed_conditions = payment_failed_conditions. retry_expected ( ) ;
124
123
}
@@ -137,7 +136,7 @@ pub fn fail_blinded_htlc_backwards(
137
136
assert_eq ! ( blinded_node_updates. update_fail_malformed_htlcs. len( ) , 1 ) ;
138
137
let update_malformed = & blinded_node_updates. update_fail_malformed_htlcs [ 0 ] ;
139
138
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 ( ) ) ;
141
140
nodes[ i-1 ] . node . handle_update_fail_malformed_htlc ( nodes[ i] . node . get_our_node_id ( ) , update_malformed) ;
142
141
do_commitment_signed_dance ( & nodes[ i-1 ] , & nodes[ i] , & blinded_node_updates. commitment_signed , true , false ) ;
143
142
}
@@ -437,11 +436,11 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
437
436
match check {
438
437
ForwardCheckFail :: ForwardPayloadEncodedAsReceive => {
439
438
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 ] ) ) ;
441
440
}
442
441
_ => {
443
442
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 ] ) ) ;
445
444
}
446
445
} ;
447
446
return
@@ -469,20 +468,20 @@ fn do_forward_checks_failure(check: ForwardCheckFail, intro_fails: bool) {
469
468
470
469
let mut updates = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
471
470
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 ( ) ) ;
473
472
assert_eq ! ( update_malformed. sha256_of_onion, [ 0 ; 32 ] ) ;
474
473
475
474
// Ensure the intro node will properly blind the error if its downstream node failed to do so.
476
475
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 ;
478
477
nodes[ 1 ] . node . handle_update_fail_malformed_htlc ( nodes[ 2 ] . node . get_our_node_id ( ) , update_malformed) ;
479
478
do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 2 ] , & updates. commitment_signed , true , false ) ;
480
479
481
480
let mut updates = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
482
481
nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
483
482
do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates. commitment_signed , false , false ) ;
484
483
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 ] ) ) ;
486
485
}
487
486
488
487
#[ test]
@@ -534,7 +533,7 @@ fn failed_backwards_to_intro_node() {
534
533
let mut updates = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
535
534
let mut update_malformed = & mut updates. update_fail_malformed_htlcs [ 0 ] ;
536
535
// 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 ( ) ) ;
538
537
assert_eq ! ( update_malformed. sha256_of_onion, [ 0 ; 32 ] ) ;
539
538
540
539
// 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() {
547
546
nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
548
547
do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates. commitment_signed , false , false ) ;
549
548
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 ] ) ) ;
551
550
}
552
551
553
552
enum ProcessPendingHTLCsCheck {
@@ -655,20 +654,20 @@ fn do_forward_fail_in_process_pending_htlc_fwds(check: ProcessPendingHTLCsCheck,
655
654
656
655
let mut updates = get_htlc_update_msgs ! ( nodes[ 2 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
657
656
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 ( ) ) ;
659
658
assert_eq ! ( update_malformed. sha256_of_onion, [ 0 ; 32 ] ) ;
660
659
661
660
// Ensure the intro node will properly blind the error if its downstream node failed to do so.
662
661
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 ;
664
663
nodes[ 1 ] . node . handle_update_fail_malformed_htlc ( nodes[ 2 ] . node . get_our_node_id ( ) , update_malformed) ;
665
664
do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 2 ] , & updates. commitment_signed , true , false ) ;
666
665
667
666
let mut updates = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
668
667
nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
669
668
do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates. commitment_signed , false , false ) ;
670
669
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 ] ) ) ;
672
671
}
673
672
674
673
#[ test]
@@ -1042,7 +1041,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
1042
1041
assert_eq ! ( updates_2_1. update_fail_malformed_htlcs. len( ) , 1 ) ;
1043
1042
let update_malformed = & updates_2_1. update_fail_malformed_htlcs [ 0 ] ;
1044
1043
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 ( ) ) ;
1046
1045
nodes[ 1 ] . node . handle_update_fail_malformed_htlc ( nodes[ 2 ] . node . get_our_node_id ( ) , update_malformed) ;
1047
1046
do_commitment_signed_dance ( & nodes[ 1 ] , & nodes[ 2 ] , & updates_2_1. commitment_signed , true , false ) ;
1048
1047
@@ -1064,7 +1063,7 @@ fn do_multi_hop_receiver_fail(check: ReceiveCheckFail) {
1064
1063
nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates_1_0. update_fail_htlcs [ 0 ] ) ;
1065
1064
do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates_1_0. commitment_signed , false , false ) ;
1066
1065
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 ] ) ) ;
1068
1067
}
1069
1068
1070
1069
#[ test]
@@ -1131,7 +1130,7 @@ fn blinded_path_retries() {
1131
1130
assert_eq!( updates. update_fail_malformed_htlcs. len( ) , 1 ) ;
1132
1131
let update_malformed = & updates. update_fail_malformed_htlcs[ 0 ] ;
1133
1132
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 ( ) ) ;
1135
1134
$intro_node. node. handle_update_fail_malformed_htlc( nodes[ 3 ] . node. get_our_node_id( ) , update_malformed) ;
1136
1135
do_commitment_signed_dance( & $intro_node, & nodes[ 3 ] , & updates. commitment_signed, true , false ) ;
1137
1136
@@ -1251,7 +1250,7 @@ fn min_htlc() {
1251
1250
nodes[ 0 ] . node . handle_update_fail_htlc ( nodes[ 1 ] . node . get_our_node_id ( ) , & updates. update_fail_htlcs [ 0 ] ) ;
1252
1251
do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & updates. commitment_signed , false , false ) ;
1253
1252
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 ] ) ) ;
1255
1254
}
1256
1255
1257
1256
#[ test]
@@ -1446,7 +1445,7 @@ fn fails_receive_tlvs_authentication() {
1446
1445
commitment_signed_dance ! ( nodes[ 0 ] , nodes[ 1 ] , update_fail. commitment_signed, false ) ;
1447
1446
expect_payment_failed_conditions (
1448
1447
& nodes[ 0 ] , payment_hash, true ,
1449
- PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( 0x4000 | 22 , & [ ] ) ,
1448
+ PaymentFailedConditions :: new ( ) . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionPayload , & [ ] ) ,
1450
1449
) ;
1451
1450
}
1452
1451
@@ -1728,7 +1727,8 @@ fn route_blinding_spec_test_vector() {
1728
1727
match onion_payment:: decode_incoming_update_add_htlc_onion (
1729
1728
& eve_update_add, & eve_node_signer, & logger, & secp_ctx
1730
1729
) {
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( ) ) ,
1732
1732
_ => panic ! ( "Unexpected error" )
1733
1733
}
1734
1734
}
@@ -2160,7 +2160,7 @@ fn do_test_trampoline_single_hop_receive(success: bool) {
2160
2160
}
2161
2161
{
2162
2162
let payment_failed_conditions = PaymentFailedConditions :: new ( )
2163
- . expected_htlc_error_data ( 0x4000 | 22 , & [ 0 ; 0 ] ) ;
2163
+ . expected_htlc_error_data ( LocalHTLCFailureReason :: InvalidOnionPayload , & [ 0 ; 0 ] ) ;
2164
2164
expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, true , payment_failed_conditions) ;
2165
2165
}
2166
2166
}
@@ -2453,10 +2453,9 @@ fn test_trampoline_forward_rejection() {
2453
2453
do_commitment_signed_dance ( & nodes[ 0 ] , & nodes[ 1 ] , & unblinded_node_updates. commitment_signed , false , false ) ;
2454
2454
}
2455
2455
{
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.
2458
2457
let payment_failed_conditions = PaymentFailedConditions :: new ( )
2459
- . expected_htlc_error_data ( 0x4000 | 10 , & [ 0 ; 0 ] ) ;
2458
+ . expected_htlc_error_data ( LocalHTLCFailureReason :: UnknownNextPeer , & [ 0 ; 0 ] ) ;
2460
2459
expect_payment_failed_conditions ( & nodes[ 0 ] , payment_hash, false , payment_failed_conditions) ;
2461
2460
}
2462
2461
}
0 commit comments