Implement writeable for APIError
[rust-lightning] / lightning / src / util / errors.rs
index b7d562e54ddb7d1bf3166aace8510ea10f62e2ff..aa740044676af69487ac06f928765862bbc7a417 100644 (file)
@@ -37,7 +37,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
@@ -84,6 +84,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 {