@@ -25,7 +25,7 @@ use core::ops::Deref;
2525
2626/// Invalid inbound onion payment.
2727#[ derive( Debug ) ]
28- pub struct InboundOnionErr {
28+ pub struct InboundHTLCErr {
2929 /// BOLT 4 error code.
3030 pub err_code : u16 ,
3131 /// Data attached to this error.
@@ -63,7 +63,7 @@ pub(super) fn create_fwd_pending_htlc_info(
6363 msg : & msgs:: UpdateAddHTLC , hop_data : msgs:: InboundOnionPayload , hop_hmac : [ u8 ; 32 ] ,
6464 new_packet_bytes : [ u8 ; onion_utils:: ONION_DATA_LEN ] , shared_secret : [ u8 ; 32 ] ,
6565 next_packet_pubkey_opt : Option < Result < PublicKey , secp256k1:: Error > >
66- ) -> Result < PendingHTLCInfo , InboundOnionErr > {
66+ ) -> Result < PendingHTLCInfo , InboundHTLCErr > {
6767 debug_assert ! ( next_packet_pubkey_opt. is_some( ) ) ;
6868 let outgoing_packet = msgs:: OnionPacket {
6969 version : 0 ,
@@ -85,7 +85,7 @@ pub(super) fn create_fwd_pending_htlc_info(
8585 ) . map_err ( |( ) | {
8686 // We should be returning malformed here if `msg.blinding_point` is set, but this is
8787 // unreachable right now since we checked it in `decode_update_add_htlc_onion`.
88- InboundOnionErr {
88+ InboundHTLCErr {
8989 msg : "Underflow calculating outbound amount or cltv value for blinded forward" ,
9090 err_code : INVALID_ONION_BLINDING ,
9191 err_data : vec ! [ 0 ; 32 ] ,
@@ -94,7 +94,7 @@ pub(super) fn create_fwd_pending_htlc_info(
9494 ( short_channel_id, amt_to_forward, outgoing_cltv_value, Some ( intro_node_blinding_point) )
9595 } ,
9696 msgs:: InboundOnionPayload :: Receive { .. } | msgs:: InboundOnionPayload :: BlindedReceive { .. } =>
97- return Err ( InboundOnionErr {
97+ return Err ( InboundHTLCErr {
9898 msg : "Final Node OnionHopData provided for us as an intermediary node" ,
9999 err_code : 0x4000 | 22 ,
100100 err_data : Vec :: new ( ) ,
@@ -120,7 +120,7 @@ pub(super) fn create_recv_pending_htlc_info(
120120 hop_data : msgs:: InboundOnionPayload , shared_secret : [ u8 ; 32 ] , payment_hash : PaymentHash ,
121121 amt_msat : u64 , cltv_expiry : u32 , phantom_shared_secret : Option < [ u8 ; 32 ] > , allow_underpay : bool ,
122122 counterparty_skimmed_fee_msat : Option < u64 > , current_height : u32 , accept_mpp_keysend : bool ,
123- ) -> Result < PendingHTLCInfo , InboundOnionErr > {
123+ ) -> Result < PendingHTLCInfo , InboundHTLCErr > {
124124 let (
125125 payment_data, keysend_preimage, custom_tlvs, onion_amt_msat, outgoing_cltv_value,
126126 payment_metadata, requires_blinded_error
@@ -136,7 +136,7 @@ pub(super) fn create_recv_pending_htlc_info(
136136 } => {
137137 check_blinded_payment_constraints ( amt_msat, cltv_expiry, & payment_constraints)
138138 . map_err ( |( ) | {
139- InboundOnionErr {
139+ InboundHTLCErr {
140140 err_code : INVALID_ONION_BLINDING ,
141141 err_data : vec ! [ 0 ; 32 ] ,
142142 msg : "Amount or cltv_expiry violated blinded payment constraints" ,
@@ -147,14 +147,14 @@ pub(super) fn create_recv_pending_htlc_info(
147147 intro_node_blinding_point. is_none ( ) )
148148 }
149149 msgs:: InboundOnionPayload :: Forward { .. } => {
150- return Err ( InboundOnionErr {
150+ return Err ( InboundHTLCErr {
151151 err_code : 0x4000 |22 ,
152152 err_data : Vec :: new ( ) ,
153153 msg : "Got non final data with an HMAC of 0" ,
154154 } )
155155 } ,
156156 msgs:: InboundOnionPayload :: BlindedForward { .. } => {
157- return Err ( InboundOnionErr {
157+ return Err ( InboundHTLCErr {
158158 err_code : INVALID_ONION_BLINDING ,
159159 err_data : vec ! [ 0 ; 32 ] ,
160160 msg : "Got blinded non final data with an HMAC of 0" ,
@@ -163,7 +163,7 @@ pub(super) fn create_recv_pending_htlc_info(
163163 } ;
164164 // final_incorrect_cltv_expiry
165165 if outgoing_cltv_value > cltv_expiry {
166- return Err ( InboundOnionErr {
166+ return Err ( InboundHTLCErr {
167167 msg : "Upstream node set CLTV to less than the CLTV set by the sender" ,
168168 err_code : 18 ,
169169 err_data : cltv_expiry. to_be_bytes ( ) . to_vec ( )
@@ -180,7 +180,7 @@ pub(super) fn create_recv_pending_htlc_info(
180180 let mut err_data = Vec :: with_capacity ( 12 ) ;
181181 err_data. extend_from_slice ( & amt_msat. to_be_bytes ( ) ) ;
182182 err_data. extend_from_slice ( & current_height. to_be_bytes ( ) ) ;
183- return Err ( InboundOnionErr {
183+ return Err ( InboundHTLCErr {
184184 err_code : 0x4000 | 15 , err_data,
185185 msg : "The final CLTV expiry is too soon to handle" ,
186186 } ) ;
@@ -189,7 +189,7 @@ pub(super) fn create_recv_pending_htlc_info(
189189 ( allow_underpay && onion_amt_msat >
190190 amt_msat. saturating_add ( counterparty_skimmed_fee_msat. unwrap_or ( 0 ) ) )
191191 {
192- return Err ( InboundOnionErr {
192+ return Err ( InboundHTLCErr {
193193 err_code : 19 ,
194194 err_data : amt_msat. to_be_bytes ( ) . to_vec ( ) ,
195195 msg : "Upstream node sent less than we were supposed to receive in payment" ,
@@ -204,14 +204,14 @@ pub(super) fn create_recv_pending_htlc_info(
204204 // time discrepancies due to a hash collision with X.
205205 let hashed_preimage = PaymentHash ( Sha256 :: hash ( & payment_preimage. 0 ) . to_byte_array ( ) ) ;
206206 if hashed_preimage != payment_hash {
207- return Err ( InboundOnionErr {
207+ return Err ( InboundHTLCErr {
208208 err_code : 0x4000 |22 ,
209209 err_data : Vec :: new ( ) ,
210210 msg : "Payment preimage didn't match payment hash" ,
211211 } ) ;
212212 }
213213 if !accept_mpp_keysend && payment_data. is_some ( ) {
214- return Err ( InboundOnionErr {
214+ return Err ( InboundHTLCErr {
215215 err_code : 0x4000 |22 ,
216216 err_data : Vec :: new ( ) ,
217217 msg : "We don't support MPP keysend payments" ,
@@ -234,7 +234,7 @@ pub(super) fn create_recv_pending_htlc_info(
234234 requires_blinded_error,
235235 }
236236 } else {
237- return Err ( InboundOnionErr {
237+ return Err ( InboundHTLCErr {
238238 err_code : 0x4000 |0x2000 |3 ,
239239 err_data : Vec :: new ( ) ,
240240 msg : "We require payment_secrets" ,
@@ -263,7 +263,7 @@ pub(super) fn create_recv_pending_htlc_info(
263263pub fn peel_payment_onion < NS : Deref , L : Deref , T : secp256k1:: Verification > (
264264 msg : & msgs:: UpdateAddHTLC , node_signer : & NS , logger : & L , secp_ctx : & Secp256k1 < T > ,
265265 cur_height : u32 , accept_mpp_keysend : bool , allow_skimmed_fees : bool ,
266- ) -> Result < PendingHTLCInfo , InboundOnionErr >
266+ ) -> Result < PendingHTLCInfo , InboundHTLCErr >
267267where
268268 NS :: Target : NodeSigner ,
269269 L :: Target : Logger ,
@@ -276,7 +276,7 @@ where
276276 HTLCFailureMsg :: Relay ( r) => ( 0x4000 | 22 , r. reason . data ) ,
277277 } ;
278278 let msg = "Failed to decode update add htlc onion" ;
279- InboundOnionErr { msg, err_code, err_data }
279+ InboundHTLCErr { msg, err_code, err_data }
280280 } ) ?;
281281 Ok ( match hop {
282282 onion_utils:: Hop :: Forward { next_hop_data, next_hop_hmac, new_packet_bytes } => {
@@ -285,7 +285,7 @@ where
285285 } = match next_packet_details_opt {
286286 Some ( next_packet_details) => next_packet_details,
287287 // Forward should always include the next hop details
288- None => return Err ( InboundOnionErr {
288+ None => return Err ( InboundHTLCErr {
289289 msg : "Failed to decode update add htlc onion" ,
290290 err_code : 0x4000 | 22 ,
291291 err_data : Vec :: new ( ) ,
@@ -295,7 +295,7 @@ where
295295 if let Err ( ( err_msg, code) ) = check_incoming_htlc_cltv (
296296 cur_height, outgoing_cltv_value, msg. cltv_expiry
297297 ) {
298- return Err ( InboundOnionErr {
298+ return Err ( InboundHTLCErr {
299299 msg : err_msg,
300300 err_code : code,
301301 err_data : Vec :: new ( ) ,
0 commit comments