X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Ferrors.rs;h=820bf31c6e090931634b2c58be1f6254060d7c98;hb=refs%2Fheads%2F2021-12-0.0.104-bindings;hp=94ad965667873aa0b8f66d2e06427a491547e611;hpb=d523b6e42b5b0fde07a89770906e0193ea987538;p=rust-lightning diff --git a/lightning/src/util/errors.rs b/lightning/src/util/errors.rs index 94ad9656..820bf31c 100644 --- a/lightning/src/util/errors.rs +++ b/lightning/src/util/errors.rs @@ -16,7 +16,7 @@ use core::fmt; /// Indicates an error on the client's part (usually some variant of attempting to use too-low or /// too-high values) -#[derive(Clone)] +#[derive(Clone, PartialEq)] pub enum APIError { /// Indicates the API was wholly misused (see err for more). Cases where these can be returned /// are documented, but generally indicates some precondition of a function was violated. @@ -66,10 +66,10 @@ pub enum APIError { impl fmt::Debug for APIError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - APIError::APIMisuseError {ref err} => f.write_str(err), + APIError::APIMisuseError {ref err} => write!(f, "Misuse error: {}", err), APIError::FeeRateTooHigh {ref err, ref feerate} => write!(f, "{} feerate: {}", err, feerate), - APIError::RouteError {ref err} => f.write_str(err), - APIError::ChannelUnavailable {ref err} => f.write_str(err), + APIError::RouteError {ref err} => write!(f, "Route error: {}", err), + APIError::ChannelUnavailable {ref err} => write!(f, "Channel unavailable: {}", err), APIError::MonitorUpdateFailed => f.write_str("Client indicated a channel monitor update failed"), APIError::IncompatibleShutdownScript { ref script } => { write!(f, "Provided a scriptpubkey format not accepted by peer: {}", script) @@ -119,6 +119,8 @@ pub(crate) fn get_onion_error_description(error_code: u16) -> (&'static str, &'s _c if _c == 19 => ("The final node indicated the amount in the HTLC does not match the value in the onion", "final_incorrect_htlc_amount"), _c if _c == UPDATE|20 => ("Node indicated the outbound channel has been disabled", "channel_disabled"), _c if _c == 21 => ("Node indicated the CLTV expiry in the HTLC is too far in the future", "expiry_too_far"), + _c if _c == PERM|22 => ("Node indicated that the decrypted onion per-hop payload was not understood by it or is incomplete", "invalid_onion_payload"), + _c if _c == 23 => ("The final node indicated the complete amount of the multi-part payment was not received within a reasonable time", "mpp_timeout"), _ => ("Unknown", ""), } }