@@ -25,7 +25,7 @@ use core::ops::Deref;
25
25
26
26
/// Invalid inbound onion payment.
27
27
#[ derive( Debug ) ]
28
- pub struct InboundOnionErr {
28
+ pub struct InboundHTLCErr {
29
29
/// BOLT 4 error code.
30
30
pub err_code : u16 ,
31
31
/// Data attached to this error.
@@ -63,7 +63,7 @@ pub(super) fn create_fwd_pending_htlc_info(
63
63
msg : & msgs:: UpdateAddHTLC , hop_data : msgs:: InboundOnionPayload , hop_hmac : [ u8 ; 32 ] ,
64
64
new_packet_bytes : [ u8 ; onion_utils:: ONION_DATA_LEN ] , shared_secret : [ u8 ; 32 ] ,
65
65
next_packet_pubkey_opt : Option < Result < PublicKey , secp256k1:: Error > >
66
- ) -> Result < PendingHTLCInfo , InboundOnionErr > {
66
+ ) -> Result < PendingHTLCInfo , InboundHTLCErr > {
67
67
debug_assert ! ( next_packet_pubkey_opt. is_some( ) ) ;
68
68
let outgoing_packet = msgs:: OnionPacket {
69
69
version : 0 ,
@@ -85,7 +85,7 @@ pub(super) fn create_fwd_pending_htlc_info(
85
85
) . map_err ( |( ) | {
86
86
// We should be returning malformed here if `msg.blinding_point` is set, but this is
87
87
// unreachable right now since we checked it in `decode_update_add_htlc_onion`.
88
- InboundOnionErr {
88
+ InboundHTLCErr {
89
89
msg : "Underflow calculating outbound amount or cltv value for blinded forward" ,
90
90
err_code : INVALID_ONION_BLINDING ,
91
91
err_data : vec ! [ 0 ; 32 ] ,
@@ -94,7 +94,7 @@ pub(super) fn create_fwd_pending_htlc_info(
94
94
( short_channel_id, amt_to_forward, outgoing_cltv_value, Some ( intro_node_blinding_point) )
95
95
} ,
96
96
msgs:: InboundOnionPayload :: Receive { .. } | msgs:: InboundOnionPayload :: BlindedReceive { .. } =>
97
- return Err ( InboundOnionErr {
97
+ return Err ( InboundHTLCErr {
98
98
msg : "Final Node OnionHopData provided for us as an intermediary node" ,
99
99
err_code : 0x4000 | 22 ,
100
100
err_data : Vec :: new ( ) ,
@@ -120,7 +120,7 @@ pub(super) fn create_recv_pending_htlc_info(
120
120
hop_data : msgs:: InboundOnionPayload , shared_secret : [ u8 ; 32 ] , payment_hash : PaymentHash ,
121
121
amt_msat : u64 , cltv_expiry : u32 , phantom_shared_secret : Option < [ u8 ; 32 ] > , allow_underpay : bool ,
122
122
counterparty_skimmed_fee_msat : Option < u64 > , current_height : u32 , accept_mpp_keysend : bool ,
123
- ) -> Result < PendingHTLCInfo , InboundOnionErr > {
123
+ ) -> Result < PendingHTLCInfo , InboundHTLCErr > {
124
124
let (
125
125
payment_data, keysend_preimage, custom_tlvs, onion_amt_msat, outgoing_cltv_value,
126
126
payment_metadata, requires_blinded_error
@@ -136,7 +136,7 @@ pub(super) fn create_recv_pending_htlc_info(
136
136
} => {
137
137
check_blinded_payment_constraints ( amt_msat, cltv_expiry, & payment_constraints)
138
138
. map_err ( |( ) | {
139
- InboundOnionErr {
139
+ InboundHTLCErr {
140
140
err_code : INVALID_ONION_BLINDING ,
141
141
err_data : vec ! [ 0 ; 32 ] ,
142
142
msg : "Amount or cltv_expiry violated blinded payment constraints" ,
@@ -147,14 +147,14 @@ pub(super) fn create_recv_pending_htlc_info(
147
147
intro_node_blinding_point. is_none ( ) )
148
148
}
149
149
msgs:: InboundOnionPayload :: Forward { .. } => {
150
- return Err ( InboundOnionErr {
150
+ return Err ( InboundHTLCErr {
151
151
err_code : 0x4000 |22 ,
152
152
err_data : Vec :: new ( ) ,
153
153
msg : "Got non final data with an HMAC of 0" ,
154
154
} )
155
155
} ,
156
156
msgs:: InboundOnionPayload :: BlindedForward { .. } => {
157
- return Err ( InboundOnionErr {
157
+ return Err ( InboundHTLCErr {
158
158
err_code : INVALID_ONION_BLINDING ,
159
159
err_data : vec ! [ 0 ; 32 ] ,
160
160
msg : "Got blinded non final data with an HMAC of 0" ,
@@ -163,7 +163,7 @@ pub(super) fn create_recv_pending_htlc_info(
163
163
} ;
164
164
// final_incorrect_cltv_expiry
165
165
if outgoing_cltv_value > cltv_expiry {
166
- return Err ( InboundOnionErr {
166
+ return Err ( InboundHTLCErr {
167
167
msg : "Upstream node set CLTV to less than the CLTV set by the sender" ,
168
168
err_code : 18 ,
169
169
err_data : cltv_expiry. to_be_bytes ( ) . to_vec ( )
@@ -180,7 +180,7 @@ pub(super) fn create_recv_pending_htlc_info(
180
180
let mut err_data = Vec :: with_capacity ( 12 ) ;
181
181
err_data. extend_from_slice ( & amt_msat. to_be_bytes ( ) ) ;
182
182
err_data. extend_from_slice ( & current_height. to_be_bytes ( ) ) ;
183
- return Err ( InboundOnionErr {
183
+ return Err ( InboundHTLCErr {
184
184
err_code : 0x4000 | 15 , err_data,
185
185
msg : "The final CLTV expiry is too soon to handle" ,
186
186
} ) ;
@@ -189,7 +189,7 @@ pub(super) fn create_recv_pending_htlc_info(
189
189
( allow_underpay && onion_amt_msat >
190
190
amt_msat. saturating_add ( counterparty_skimmed_fee_msat. unwrap_or ( 0 ) ) )
191
191
{
192
- return Err ( InboundOnionErr {
192
+ return Err ( InboundHTLCErr {
193
193
err_code : 19 ,
194
194
err_data : amt_msat. to_be_bytes ( ) . to_vec ( ) ,
195
195
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(
204
204
// time discrepancies due to a hash collision with X.
205
205
let hashed_preimage = PaymentHash ( Sha256 :: hash ( & payment_preimage. 0 ) . to_byte_array ( ) ) ;
206
206
if hashed_preimage != payment_hash {
207
- return Err ( InboundOnionErr {
207
+ return Err ( InboundHTLCErr {
208
208
err_code : 0x4000 |22 ,
209
209
err_data : Vec :: new ( ) ,
210
210
msg : "Payment preimage didn't match payment hash" ,
211
211
} ) ;
212
212
}
213
213
if !accept_mpp_keysend && payment_data. is_some ( ) {
214
- return Err ( InboundOnionErr {
214
+ return Err ( InboundHTLCErr {
215
215
err_code : 0x4000 |22 ,
216
216
err_data : Vec :: new ( ) ,
217
217
msg : "We don't support MPP keysend payments" ,
@@ -234,7 +234,7 @@ pub(super) fn create_recv_pending_htlc_info(
234
234
requires_blinded_error,
235
235
}
236
236
} else {
237
- return Err ( InboundOnionErr {
237
+ return Err ( InboundHTLCErr {
238
238
err_code : 0x4000 |0x2000 |3 ,
239
239
err_data : Vec :: new ( ) ,
240
240
msg : "We require payment_secrets" ,
@@ -263,7 +263,7 @@ pub(super) fn create_recv_pending_htlc_info(
263
263
pub fn peel_payment_onion < NS : Deref , L : Deref , T : secp256k1:: Verification > (
264
264
msg : & msgs:: UpdateAddHTLC , node_signer : & NS , logger : & L , secp_ctx : & Secp256k1 < T > ,
265
265
cur_height : u32 , accept_mpp_keysend : bool , allow_skimmed_fees : bool ,
266
- ) -> Result < PendingHTLCInfo , InboundOnionErr >
266
+ ) -> Result < PendingHTLCInfo , InboundHTLCErr >
267
267
where
268
268
NS :: Target : NodeSigner ,
269
269
L :: Target : Logger ,
@@ -276,7 +276,7 @@ where
276
276
HTLCFailureMsg :: Relay ( r) => ( 0x4000 | 22 , r. reason . data ) ,
277
277
} ;
278
278
let msg = "Failed to decode update add htlc onion" ;
279
- InboundOnionErr { msg, err_code, err_data }
279
+ InboundHTLCErr { msg, err_code, err_data }
280
280
} ) ?;
281
281
Ok ( match hop {
282
282
onion_utils:: Hop :: Forward { next_hop_data, next_hop_hmac, new_packet_bytes } => {
@@ -285,7 +285,7 @@ where
285
285
} = match next_packet_details_opt {
286
286
Some ( next_packet_details) => next_packet_details,
287
287
// Forward should always include the next hop details
288
- None => return Err ( InboundOnionErr {
288
+ None => return Err ( InboundHTLCErr {
289
289
msg : "Failed to decode update add htlc onion" ,
290
290
err_code : 0x4000 | 22 ,
291
291
err_data : Vec :: new ( ) ,
@@ -295,7 +295,7 @@ where
295
295
if let Err ( ( err_msg, code) ) = check_incoming_htlc_cltv (
296
296
cur_height, outgoing_cltv_value, msg. cltv_expiry
297
297
) {
298
- return Err ( InboundOnionErr {
298
+ return Err ( InboundHTLCErr {
299
299
msg : err_msg,
300
300
err_code : code,
301
301
err_data : Vec :: new ( ) ,
0 commit comments