@@ -29,7 +29,7 @@ use core::ops::Deref;
2929#[ derive( Clone , Debug , Hash , PartialEq , Eq ) ]
3030pub struct InboundHTLCErr {
3131 /// BOLT 4 error code.
32- pub err_code : LocalHTLCFailureReason ,
32+ pub reason : LocalHTLCFailureReason ,
3333 /// Data attached to this error.
3434 pub err_data : Vec < u8 > ,
3535 /// Error message text.
@@ -110,7 +110,7 @@ pub(super) fn create_fwd_pending_htlc_info(
110110 // unreachable right now since we checked it in `decode_update_add_htlc_onion`.
111111 InboundHTLCErr {
112112 msg : "Underflow calculating outbound amount or cltv value for blinded forward" ,
113- err_code : LocalHTLCFailureReason :: InvalidOnionBlinding ,
113+ reason : LocalHTLCFailureReason :: InvalidOnionBlinding ,
114114 err_data : vec ! [ 0 ; 32 ] ,
115115 }
116116 } ) ?;
@@ -120,13 +120,13 @@ pub(super) fn create_fwd_pending_htlc_info(
120120 onion_utils:: Hop :: Receive { .. } | onion_utils:: Hop :: BlindedReceive { .. } =>
121121 return Err ( InboundHTLCErr {
122122 msg : "Final Node OnionHopData provided for us as an intermediary node" ,
123- err_code : LocalHTLCFailureReason :: InvalidOnionPayload ,
123+ reason : LocalHTLCFailureReason :: InvalidOnionPayload ,
124124 err_data : Vec :: new ( ) ,
125125 } ) ,
126126 onion_utils:: Hop :: TrampolineReceive { .. } | onion_utils:: Hop :: TrampolineBlindedReceive { .. } =>
127127 return Err ( InboundHTLCErr {
128128 msg : "Final Node OnionHopData provided for us as an intermediary node" ,
129- err_code : LocalHTLCFailureReason :: InvalidOnionPayload ,
129+ reason : LocalHTLCFailureReason :: InvalidOnionPayload ,
130130 err_data : Vec :: new ( ) ,
131131 } ) ,
132132 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(
152152 // unreachable right now since we checked it in `decode_update_add_htlc_onion`.
153153 InboundHTLCErr {
154154 msg : "Underflow calculating outbound amount or cltv value for blinded forward" ,
155- err_code : LocalHTLCFailureReason :: InvalidOnionBlinding ,
155+ reason : LocalHTLCFailureReason :: InvalidOnionBlinding ,
156156 err_data : vec ! [ 0 ; 32 ] ,
157157 }
158158 } ) ?;
@@ -199,7 +199,7 @@ pub(super) fn create_fwd_pending_htlc_info(
199199 Some ( Ok ( pubkey) ) => pubkey,
200200 _ => return Err ( InboundHTLCErr {
201201 msg : "Missing next Trampoline hop pubkey from intermediate Trampoline forwarding data" ,
202- err_code : LocalHTLCFailureReason :: InvalidOnionPayload ,
202+ reason : LocalHTLCFailureReason :: InvalidOnionPayload ,
203203 err_data : Vec :: new ( ) ,
204204 } ) ,
205205 } ;
@@ -263,7 +263,7 @@ pub(super) fn create_recv_pending_htlc_info(
263263 )
264264 . map_err ( |( ) | {
265265 InboundHTLCErr {
266- err_code : LocalHTLCFailureReason :: InvalidOnionBlinding ,
266+ reason : LocalHTLCFailureReason :: InvalidOnionBlinding ,
267267 err_data : vec ! [ 0 ; 32 ] ,
268268 msg : "Amount or cltv_expiry violated blinded payment constraints" ,
269269 }
@@ -293,7 +293,7 @@ pub(super) fn create_recv_pending_htlc_info(
293293 )
294294 . map_err ( |( ) | {
295295 InboundHTLCErr {
296- err_code : LocalHTLCFailureReason :: InvalidOnionBlinding ,
296+ reason : LocalHTLCFailureReason :: InvalidOnionBlinding ,
297297 err_data : vec ! [ 0 ; 32 ] ,
298298 msg : "Amount or cltv_expiry violated blinded payment constraints within Trampoline onion" ,
299299 }
@@ -305,21 +305,21 @@ pub(super) fn create_recv_pending_htlc_info(
305305 } ,
306306 onion_utils:: Hop :: Forward { .. } => {
307307 return Err ( InboundHTLCErr {
308- err_code : LocalHTLCFailureReason :: InvalidOnionPayload ,
308+ reason : LocalHTLCFailureReason :: InvalidOnionPayload ,
309309 err_data : Vec :: new ( ) ,
310310 msg : "Got non final data with an HMAC of 0" ,
311311 } )
312312 } ,
313313 onion_utils:: Hop :: BlindedForward { .. } => {
314314 return Err ( InboundHTLCErr {
315- err_code : LocalHTLCFailureReason :: InvalidOnionBlinding ,
315+ reason : LocalHTLCFailureReason :: InvalidOnionBlinding ,
316316 err_data : vec ! [ 0 ; 32 ] ,
317317 msg : "Got blinded non final data with an HMAC of 0" ,
318318 } )
319319 } ,
320320 onion_utils:: Hop :: TrampolineForward { .. } | onion_utils:: Hop :: TrampolineBlindedForward { .. } => {
321321 return Err ( InboundHTLCErr {
322- err_code : LocalHTLCFailureReason :: InvalidOnionPayload ,
322+ reason : LocalHTLCFailureReason :: InvalidOnionPayload ,
323323 err_data : Vec :: new ( ) ,
324324 msg : "Got Trampoline non final data with an HMAC of 0" ,
325325 } )
@@ -329,7 +329,7 @@ pub(super) fn create_recv_pending_htlc_info(
329329 if onion_cltv_expiry > cltv_expiry {
330330 return Err ( InboundHTLCErr {
331331 msg : "Upstream node set CLTV to less than the CLTV set by the sender" ,
332- err_code : LocalHTLCFailureReason :: FinalIncorrectCLTVExpiry ,
332+ reason : LocalHTLCFailureReason :: FinalIncorrectCLTVExpiry ,
333333 err_data : cltv_expiry. to_be_bytes ( ) . to_vec ( )
334334 } )
335335 }
@@ -342,7 +342,7 @@ pub(super) fn create_recv_pending_htlc_info(
342342 // channel closure (see HTLC_FAIL_BACK_BUFFER rationale).
343343 if cltv_expiry <= current_height + HTLC_FAIL_BACK_BUFFER + 1 {
344344 return Err ( InboundHTLCErr {
345- err_code : LocalHTLCFailureReason :: IncorrectPaymentDetails ,
345+ reason : LocalHTLCFailureReason :: IncorrectPaymentDetails ,
346346 err_data : invalid_payment_err_data ( amt_msat, current_height) ,
347347 msg : "The final CLTV expiry is too soon to handle" ,
348348 } ) ;
@@ -352,7 +352,7 @@ pub(super) fn create_recv_pending_htlc_info(
352352 amt_msat. saturating_add ( counterparty_skimmed_fee_msat. unwrap_or ( 0 ) ) )
353353 {
354354 return Err ( InboundHTLCErr {
355- err_code : LocalHTLCFailureReason :: FinalIncorrectHTLCAmount ,
355+ reason : LocalHTLCFailureReason :: FinalIncorrectHTLCAmount ,
356356 err_data : amt_msat. to_be_bytes ( ) . to_vec ( ) ,
357357 msg : "Upstream node sent less than we were supposed to receive in payment" ,
358358 } ) ;
@@ -367,7 +367,7 @@ pub(super) fn create_recv_pending_htlc_info(
367367 let hashed_preimage = PaymentHash ( Sha256 :: hash ( & payment_preimage. 0 ) . to_byte_array ( ) ) ;
368368 if hashed_preimage != payment_hash {
369369 return Err ( InboundHTLCErr {
370- err_code : LocalHTLCFailureReason :: IncorrectPaymentDetails ,
370+ reason : LocalHTLCFailureReason :: IncorrectPaymentDetails ,
371371 err_data : invalid_payment_err_data ( amt_msat, current_height) ,
372372 msg : "Payment preimage didn't match payment hash" ,
373373 } ) ;
@@ -395,7 +395,7 @@ pub(super) fn create_recv_pending_htlc_info(
395395 }
396396 } else {
397397 return Err ( InboundHTLCErr {
398- err_code : LocalHTLCFailureReason :: RequiredNodeFeature ,
398+ reason : LocalHTLCFailureReason :: RequiredNodeFeature ,
399399 err_data : Vec :: new ( ) ,
400400 msg : "We require payment_secrets" ,
401401 } ) ;
@@ -431,12 +431,12 @@ where
431431 let ( hop, next_packet_details_opt) =
432432 decode_incoming_update_add_htlc_onion ( msg, node_signer, logger, secp_ctx
433433 ) . map_err ( |( msg, failure_reason) | {
434- let ( err_code , err_data) = match msg {
434+ let ( reason , err_data) = match msg {
435435 HTLCFailureMsg :: Malformed ( _) => ( failure_reason, Vec :: new ( ) ) ,
436436 HTLCFailureMsg :: Relay ( r) => ( LocalHTLCFailureReason :: InvalidOnionPayload , r. reason ) ,
437437 } ;
438438 let msg = "Failed to decode update add htlc onion" ;
439- InboundHTLCErr { msg, err_code , err_data }
439+ InboundHTLCErr { msg, reason , err_data }
440440 } ) ?;
441441 Ok ( match hop {
442442 onion_utils:: Hop :: Forward { shared_secret, .. } |
@@ -448,17 +448,17 @@ where
448448 // Forward should always include the next hop details
449449 None => return Err ( InboundHTLCErr {
450450 msg : "Failed to decode update add htlc onion" ,
451- err_code : LocalHTLCFailureReason :: InvalidOnionPayload ,
451+ reason : LocalHTLCFailureReason :: InvalidOnionPayload ,
452452 err_data : Vec :: new ( ) ,
453453 } ) ,
454454 } ;
455455
456- if let Err ( ( err_msg, err_code ) ) = check_incoming_htlc_cltv (
456+ if let Err ( ( err_msg, reason ) ) = check_incoming_htlc_cltv (
457457 cur_height, outgoing_cltv_value, msg. cltv_expiry ,
458458 ) {
459459 return Err ( InboundHTLCErr {
460460 msg : err_msg,
461- err_code ,
461+ reason ,
462462 err_data : Vec :: new ( ) ,
463463 } ) ;
464464 }
0 commit comments