X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Ferrors.rs;h=735ce044f810b6a4f9aa97e500c1c628cd43ee4d;hb=ac6d4cb9ad45189e963bd906e9da971502dff129;hp=b7d562e54ddb7d1bf3166aace8510ea10f62e2ff;hpb=d8a20eda5f74126d96700263716ee3938d4d3c8d;p=rust-lightning diff --git a/lightning/src/util/errors.rs b/lightning/src/util/errors.rs index b7d562e5..735ce044 100644 --- a/lightning/src/util/errors.rs +++ b/lightning/src/util/errors.rs @@ -11,7 +11,9 @@ use crate::ln::script::ShutdownScript; -use alloc::string::String; +#[allow(unused_imports)] +use crate::prelude::*; + use core::fmt; /// Indicates an error on the client's part (usually some variant of attempting to use too-low or @@ -37,7 +39,7 @@ pub enum APIError { /// too-many-hops, etc). InvalidRoute { /// A human-readable error message - err: &'static str + err: String }, /// We were unable to complete the request as the Channel required to do so is unable to /// complete the request (or was not found). This can take many forms, including disconnected @@ -61,7 +63,7 @@ pub enum APIError { /// Using a SegWit v0 script should resolve this issue. If you cannot, you won't be able to open /// a channel or cooperatively close one with this peer (and will have to force-close instead). /// - /// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::SignerProvider::get_shutdown_scriptpubkey + /// [`SignerProvider::get_shutdown_scriptpubkey`]: crate::sign::SignerProvider::get_shutdown_scriptpubkey /// [`InitFeatures`]: crate::ln::features::InitFeatures IncompatibleShutdownScript { /// The incompatible shutdown script. @@ -84,6 +86,18 @@ impl fmt::Debug for APIError { } } +impl_writeable_tlv_based_enum_upgradable!(APIError, + (0, APIMisuseError) => { (0, err, required), }, + (2, FeeRateTooHigh) => { + (0, err, required), + (2, feerate, required), + }, + (4, InvalidRoute) => { (0, err, required), }, + (6, ChannelUnavailable) => { (0, err, required), }, + (8, MonitorUpdateInProgress) => {}, + (10, IncompatibleShutdownScript) => { (0, script, required), }, +); + #[inline] pub(crate) fn get_onion_debug_field(error_code: u16) -> (&'static str, usize) { match error_code & 0xff {