@@ -29,7 +29,7 @@ use core::ops::Deref;
29
29
#[ derive( Clone , Debug , Hash , PartialEq , Eq ) ]
30
30
pub struct InboundHTLCErr {
31
31
/// BOLT 4 error code.
32
- pub err_code : LocalHTLCFailureReason ,
32
+ pub reason : LocalHTLCFailureReason ,
33
33
/// Data attached to this error.
34
34
pub err_data : Vec < u8 > ,
35
35
/// Error message text.
@@ -110,7 +110,7 @@ pub(super) fn create_fwd_pending_htlc_info(
110
110
// unreachable right now since we checked it in `decode_update_add_htlc_onion`.
111
111
InboundHTLCErr {
112
112
msg : "Underflow calculating outbound amount or cltv value for blinded forward" ,
113
- err_code : LocalHTLCFailureReason :: InvalidOnionBlinding ,
113
+ reason : LocalHTLCFailureReason :: InvalidOnionBlinding ,
114
114
err_data : vec ! [ 0 ; 32 ] ,
115
115
}
116
116
} ) ?;
@@ -120,13 +120,13 @@ pub(super) fn create_fwd_pending_htlc_info(
120
120
onion_utils:: Hop :: Receive { .. } | onion_utils:: Hop :: BlindedReceive { .. } =>
121
121
return Err ( InboundHTLCErr {
122
122
msg : "Final Node OnionHopData provided for us as an intermediary node" ,
123
- err_code : LocalHTLCFailureReason :: InvalidOnionPayload ,
123
+ reason : LocalHTLCFailureReason :: InvalidOnionPayload ,
124
124
err_data : Vec :: new ( ) ,
125
125
} ) ,
126
126
onion_utils:: Hop :: TrampolineReceive { .. } | onion_utils:: Hop :: TrampolineBlindedReceive { .. } =>
127
127
return Err ( InboundHTLCErr {
128
128
msg : "Final Node OnionHopData provided for us as an intermediary node" ,
129
- err_code : LocalHTLCFailureReason :: InvalidOnionPayload ,
129
+ reason : LocalHTLCFailureReason :: InvalidOnionPayload ,
130
130
err_data : Vec :: new ( ) ,
131
131
} ) ,
132
132
onion_utils:: Hop :: TrampolineForward { next_trampoline_hop_data, next_trampoline_hop_hmac, new_trampoline_packet_bytes, trampoline_shared_secret, .. } => {
@@ -152,7 +152,7 @@ pub(super) fn create_fwd_pending_htlc_info(
152
152
// unreachable right now since we checked it in `decode_update_add_htlc_onion`.
153
153
InboundHTLCErr {
154
154
msg : "Underflow calculating outbound amount or cltv value for blinded forward" ,
155
- err_code : LocalHTLCFailureReason :: InvalidOnionBlinding ,
155
+ reason : LocalHTLCFailureReason :: InvalidOnionBlinding ,
156
156
err_data : vec ! [ 0 ; 32 ] ,
157
157
}
158
158
} ) ?;
@@ -199,7 +199,7 @@ pub(super) fn create_fwd_pending_htlc_info(
199
199
Some ( Ok ( pubkey) ) => pubkey,
200
200
_ => return Err ( InboundHTLCErr {
201
201
msg : "Missing next Trampoline hop pubkey from intermediate Trampoline forwarding data" ,
202
- err_code : LocalHTLCFailureReason :: InvalidOnionPayload ,
202
+ reason : LocalHTLCFailureReason :: InvalidOnionPayload ,
203
203
err_data : Vec :: new ( ) ,
204
204
} ) ,
205
205
} ;
@@ -263,7 +263,7 @@ pub(super) fn create_recv_pending_htlc_info(
263
263
)
264
264
. map_err ( |( ) | {
265
265
InboundHTLCErr {
266
- err_code : LocalHTLCFailureReason :: InvalidOnionBlinding ,
266
+ reason : LocalHTLCFailureReason :: InvalidOnionBlinding ,
267
267
err_data : vec ! [ 0 ; 32 ] ,
268
268
msg : "Amount or cltv_expiry violated blinded payment constraints" ,
269
269
}
@@ -293,7 +293,7 @@ pub(super) fn create_recv_pending_htlc_info(
293
293
)
294
294
. map_err ( |( ) | {
295
295
InboundHTLCErr {
296
- err_code : LocalHTLCFailureReason :: InvalidOnionBlinding ,
296
+ reason : LocalHTLCFailureReason :: InvalidOnionBlinding ,
297
297
err_data : vec ! [ 0 ; 32 ] ,
298
298
msg : "Amount or cltv_expiry violated blinded payment constraints within Trampoline onion" ,
299
299
}
@@ -305,21 +305,21 @@ pub(super) fn create_recv_pending_htlc_info(
305
305
} ,
306
306
onion_utils:: Hop :: Forward { .. } => {
307
307
return Err ( InboundHTLCErr {
308
- err_code : LocalHTLCFailureReason :: InvalidOnionPayload ,
308
+ reason : LocalHTLCFailureReason :: InvalidOnionPayload ,
309
309
err_data : Vec :: new ( ) ,
310
310
msg : "Got non final data with an HMAC of 0" ,
311
311
} )
312
312
} ,
313
313
onion_utils:: Hop :: BlindedForward { .. } => {
314
314
return Err ( InboundHTLCErr {
315
- err_code : LocalHTLCFailureReason :: InvalidOnionBlinding ,
315
+ reason : LocalHTLCFailureReason :: InvalidOnionBlinding ,
316
316
err_data : vec ! [ 0 ; 32 ] ,
317
317
msg : "Got blinded non final data with an HMAC of 0" ,
318
318
} )
319
319
} ,
320
320
onion_utils:: Hop :: TrampolineForward { .. } | onion_utils:: Hop :: TrampolineBlindedForward { .. } => {
321
321
return Err ( InboundHTLCErr {
322
- err_code : LocalHTLCFailureReason :: InvalidOnionPayload ,
322
+ reason : LocalHTLCFailureReason :: InvalidOnionPayload ,
323
323
err_data : Vec :: new ( ) ,
324
324
msg : "Got Trampoline non final data with an HMAC of 0" ,
325
325
} )
@@ -329,7 +329,7 @@ pub(super) fn create_recv_pending_htlc_info(
329
329
if onion_cltv_expiry > cltv_expiry {
330
330
return Err ( InboundHTLCErr {
331
331
msg : "Upstream node set CLTV to less than the CLTV set by the sender" ,
332
- err_code : LocalHTLCFailureReason :: FinalIncorrectCLTVExpiry ,
332
+ reason : LocalHTLCFailureReason :: FinalIncorrectCLTVExpiry ,
333
333
err_data : cltv_expiry. to_be_bytes ( ) . to_vec ( )
334
334
} )
335
335
}
@@ -342,7 +342,7 @@ pub(super) fn create_recv_pending_htlc_info(
342
342
// channel closure (see HTLC_FAIL_BACK_BUFFER rationale).
343
343
if cltv_expiry <= current_height + HTLC_FAIL_BACK_BUFFER + 1 {
344
344
return Err ( InboundHTLCErr {
345
- err_code : LocalHTLCFailureReason :: IncorrectPaymentDetails ,
345
+ reason : LocalHTLCFailureReason :: IncorrectPaymentDetails ,
346
346
err_data : invalid_payment_err_data ( amt_msat, current_height) ,
347
347
msg : "The final CLTV expiry is too soon to handle" ,
348
348
} ) ;
@@ -352,7 +352,7 @@ pub(super) fn create_recv_pending_htlc_info(
352
352
amt_msat. saturating_add ( counterparty_skimmed_fee_msat. unwrap_or ( 0 ) ) )
353
353
{
354
354
return Err ( InboundHTLCErr {
355
- err_code : LocalHTLCFailureReason :: FinalIncorrectHTLCAmount ,
355
+ reason : LocalHTLCFailureReason :: FinalIncorrectHTLCAmount ,
356
356
err_data : amt_msat. to_be_bytes ( ) . to_vec ( ) ,
357
357
msg : "Upstream node sent less than we were supposed to receive in payment" ,
358
358
} ) ;
@@ -367,7 +367,7 @@ pub(super) fn create_recv_pending_htlc_info(
367
367
let hashed_preimage = PaymentHash ( Sha256 :: hash ( & payment_preimage. 0 ) . to_byte_array ( ) ) ;
368
368
if hashed_preimage != payment_hash {
369
369
return Err ( InboundHTLCErr {
370
- err_code : LocalHTLCFailureReason :: IncorrectPaymentDetails ,
370
+ reason : LocalHTLCFailureReason :: IncorrectPaymentDetails ,
371
371
err_data : invalid_payment_err_data ( amt_msat, current_height) ,
372
372
msg : "Payment preimage didn't match payment hash" ,
373
373
} ) ;
@@ -395,7 +395,7 @@ pub(super) fn create_recv_pending_htlc_info(
395
395
}
396
396
} else {
397
397
return Err ( InboundHTLCErr {
398
- err_code : LocalHTLCFailureReason :: RequiredNodeFeature ,
398
+ reason : LocalHTLCFailureReason :: RequiredNodeFeature ,
399
399
err_data : Vec :: new ( ) ,
400
400
msg : "We require payment_secrets" ,
401
401
} ) ;
@@ -431,12 +431,12 @@ where
431
431
let ( hop, next_packet_details_opt) =
432
432
decode_incoming_update_add_htlc_onion ( msg, node_signer, logger, secp_ctx
433
433
) . map_err ( |( msg, failure_reason) | {
434
- let ( err_code , err_data) = match msg {
434
+ let ( reason , err_data) = match msg {
435
435
HTLCFailureMsg :: Malformed ( _) => ( failure_reason, Vec :: new ( ) ) ,
436
436
HTLCFailureMsg :: Relay ( r) => ( LocalHTLCFailureReason :: InvalidOnionPayload , r. reason ) ,
437
437
} ;
438
438
let msg = "Failed to decode update add htlc onion" ;
439
- InboundHTLCErr { msg, err_code , err_data }
439
+ InboundHTLCErr { msg, reason , err_data }
440
440
} ) ?;
441
441
Ok ( match hop {
442
442
onion_utils:: Hop :: Forward { shared_secret, .. } |
@@ -448,17 +448,17 @@ where
448
448
// Forward should always include the next hop details
449
449
None => return Err ( InboundHTLCErr {
450
450
msg : "Failed to decode update add htlc onion" ,
451
- err_code : LocalHTLCFailureReason :: InvalidOnionPayload ,
451
+ reason : LocalHTLCFailureReason :: InvalidOnionPayload ,
452
452
err_data : Vec :: new ( ) ,
453
453
} ) ,
454
454
} ;
455
455
456
- if let Err ( ( err_msg, err_code ) ) = check_incoming_htlc_cltv (
456
+ if let Err ( ( err_msg, reason ) ) = check_incoming_htlc_cltv (
457
457
cur_height, outgoing_cltv_value, msg. cltv_expiry ,
458
458
) {
459
459
return Err ( InboundHTLCErr {
460
460
msg : err_msg,
461
- err_code ,
461
+ reason ,
462
462
err_data : Vec :: new ( ) ,
463
463
} ) ;
464
464
}
0 commit comments