@@ -2419,10 +2419,10 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
2419
2419
let session_priv = SecretKey :: from_slice ( & session_priv_bytes[ ..] ) . expect ( "RNG is busted" ) ;
2420
2420
2421
2421
let onion_keys = onion_utils:: construct_onion_keys ( & self . secp_ctx , & path, & session_priv)
2422
- . map_err ( |_| APIError :: RouteError { err : "Pubkey along hop was maliciously selected" } ) ?;
2422
+ . map_err ( |_| APIError :: InvalidRoute { err : "Pubkey along hop was maliciously selected" } ) ?;
2423
2423
let ( onion_payloads, htlc_msat, htlc_cltv) = onion_utils:: build_onion_payloads ( path, total_value, payment_secret, cur_height, keysend_preimage) ?;
2424
2424
if onion_utils:: route_size_insane ( & onion_payloads) {
2425
- return Err ( APIError :: RouteError { err : "Route size too large considering onion data" } ) ;
2425
+ return Err ( APIError :: InvalidRoute { err : "Route size too large considering onion data" } ) ;
2426
2426
}
2427
2427
let onion_packet = onion_utils:: construct_onion_packet ( onion_payloads, onion_keys, prng_seed, payment_hash) ;
2428
2428
@@ -2439,7 +2439,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
2439
2439
if let hash_map:: Entry :: Occupied ( mut chan) = channel_state. by_id . entry ( id) {
2440
2440
match {
2441
2441
if chan. get ( ) . get_counterparty_node_id ( ) != path. first ( ) . unwrap ( ) . pubkey {
2442
- return Err ( APIError :: RouteError { err : "Node ID mismatch on first hop!" } ) ;
2442
+ return Err ( APIError :: InvalidRoute { err : "Node ID mismatch on first hop!" } ) ;
2443
2443
}
2444
2444
if !chan. get ( ) . is_live ( ) {
2445
2445
return Err ( APIError :: ChannelUnavailable { err : "Peer for first hop currently disconnected/pending monitor update!" . to_owned ( ) } ) ;
@@ -2514,7 +2514,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
2514
2514
/// fields for more info.
2515
2515
///
2516
2516
/// If a pending payment is currently in-flight with the same [`PaymentId`] provided, this
2517
- /// method will error with an [`APIError::RouteError `]. Note, however, that once a payment
2517
+ /// method will error with an [`APIError::InvalidRoute `]. Note, however, that once a payment
2518
2518
/// is no longer pending (either via [`ChannelManager::abandon_payment`], or handling of an
2519
2519
/// [`Event::PaymentSent`]) LDK will not stop you from sending a second payment with the same
2520
2520
/// [`PaymentId`].
@@ -2533,7 +2533,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
2533
2533
/// PaymentSendFailure for more info.
2534
2534
///
2535
2535
/// In general, a path may raise:
2536
- /// * [`APIError::RouteError `] when an invalid route or forwarding parameter (cltv_delta, fee,
2536
+ /// * [`APIError::InvalidRoute `] when an invalid route or forwarding parameter (cltv_delta, fee,
2537
2537
/// node public key) is specified.
2538
2538
/// * [`APIError::ChannelUnavailable`] if the next-hop channel is not available for updates
2539
2539
/// (including due to previous monitor update failure or new permanent monitor update
@@ -2598,7 +2598,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
2598
2598
2599
2599
fn send_payment_internal ( & self , route : & Route , payment_hash : PaymentHash , payment_secret : & Option < PaymentSecret > , keysend_preimage : Option < PaymentPreimage > , payment_id : PaymentId , recv_value_msat : Option < u64 > , onion_session_privs : Vec < [ u8 ; 32 ] > ) -> Result < ( ) , PaymentSendFailure > {
2600
2600
if route. paths . len ( ) < 1 {
2601
- return Err ( PaymentSendFailure :: ParameterError ( APIError :: RouteError { err : "There must be at least one path to send over" } ) ) ;
2601
+ return Err ( PaymentSendFailure :: ParameterError ( APIError :: InvalidRoute { err : "There must be at least one path to send over" } ) ) ;
2602
2602
}
2603
2603
if payment_secret. is_none ( ) && route. paths . len ( ) > 1 {
2604
2604
return Err ( PaymentSendFailure :: ParameterError ( APIError :: APIMisuseError { err : "Payment secret is required for multi-path payments" . to_string ( ) } ) ) ;
@@ -2608,12 +2608,12 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
2608
2608
let mut path_errs = Vec :: with_capacity ( route. paths . len ( ) ) ;
2609
2609
' path_check: for path in route. paths . iter ( ) {
2610
2610
if path. len ( ) < 1 || path. len ( ) > 20 {
2611
- path_errs. push ( Err ( APIError :: RouteError { err : "Path didn't go anywhere/had bogus size" } ) ) ;
2611
+ path_errs. push ( Err ( APIError :: InvalidRoute { err : "Path didn't go anywhere/had bogus size" } ) ) ;
2612
2612
continue ' path_check;
2613
2613
}
2614
2614
for ( idx, hop) in path. iter ( ) . enumerate ( ) {
2615
2615
if idx != path. len ( ) - 1 && hop. pubkey == our_node_id {
2616
- path_errs. push ( Err ( APIError :: RouteError { err : "Path went through us but wasn't a simple rebalance loop to us" } ) ) ;
2616
+ path_errs. push ( Err ( APIError :: InvalidRoute { err : "Path went through us but wasn't a simple rebalance loop to us" } ) ) ;
2617
2617
continue ' path_check;
2618
2618
}
2619
2619
}
@@ -3092,20 +3092,20 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3092
3092
let next_hop_scid = match self . channel_state . lock ( ) . unwrap ( ) . by_id . get ( next_hop_channel_id) {
3093
3093
Some ( chan) => {
3094
3094
if !chan. is_usable ( ) {
3095
- return Err ( APIError :: APIMisuseError {
3096
- err : format ! ( "Channel with id {:? } not fully established" , next_hop_channel_id)
3095
+ return Err ( APIError :: ChannelUnavailable {
3096
+ err : format ! ( "Channel with id {} not fully established" , log_bytes! ( * next_hop_channel_id) )
3097
3097
} )
3098
3098
}
3099
3099
chan. get_short_channel_id ( ) . unwrap_or ( chan. outbound_scid_alias ( ) )
3100
3100
} ,
3101
- None => return Err ( APIError :: APIMisuseError {
3102
- err : format ! ( "Channel with id {:? } not found" , next_hop_channel_id)
3101
+ None => return Err ( APIError :: ChannelUnavailable {
3102
+ err : format ! ( "Channel with id {} not found" , log_bytes! ( * next_hop_channel_id) )
3103
3103
} )
3104
3104
} ;
3105
3105
3106
3106
let payment = self . pending_intercepted_htlcs . lock ( ) . unwrap ( ) . remove ( & intercept_id)
3107
3107
. ok_or_else ( || APIError :: APIMisuseError {
3108
- err : format ! ( "Payment with intercept id {:? } not found" , intercept_id. 0 )
3108
+ err : format ! ( "Payment with intercept id {} not found" , log_bytes! ( intercept_id. 0 ) )
3109
3109
} ) ?;
3110
3110
3111
3111
let routing = match payment. forward_info . routing {
@@ -3140,7 +3140,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
3140
3140
3141
3141
let payment = self . pending_intercepted_htlcs . lock ( ) . unwrap ( ) . remove ( & intercept_id)
3142
3142
. ok_or_else ( || APIError :: APIMisuseError {
3143
- err : format ! ( "Payment with InterceptId {:? } not found" , intercept_id)
3143
+ err : format ! ( "Payment with intercept id { } not found" , log_bytes! ( intercept_id. 0 ) )
3144
3144
} ) ?;
3145
3145
3146
3146
if let PendingHTLCRouting :: Forward { short_channel_id, .. } = payment. forward_info . routing {
0 commit comments