X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Ferrors.rs;h=94ad965667873aa0b8f66d2e06427a491547e611;hb=59659d3171141a4aab65d24462786578aa1aeaf1;hp=1b29916e0f56b5e700032ebdff470253eb48f30b;hpb=f91718722af63bd6dfb960340d539c093c0288aa;p=rust-lightning diff --git a/lightning/src/util/errors.rs b/lightning/src/util/errors.rs index 1b29916e..94ad9656 100644 --- a/lightning/src/util/errors.rs +++ b/lightning/src/util/errors.rs @@ -1,15 +1,28 @@ +// This file is Copyright its original authors, visible in version control +// history. +// +// This file is licensed under the Apache License, Version 2.0 or the MIT license +// , at your option. +// You may not use this file except in accordance with one or both of these +// licenses. + //! Error types live here. -use std::fmt; +use ln::script::ShutdownScript; + +use alloc::string::String; +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)] 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. APIMisuseError { /// A human-readable error message - err: &'static str + err: String }, /// Due to a high feerate, we were unable to complete the request. /// For example, this may be returned if the feerate implies we cannot open a channel at the @@ -31,11 +44,23 @@ pub enum APIError { /// peer, channel at capacity, channel shutting down, etc. ChannelUnavailable { /// A human-readable error message - err: &'static str + err: String }, - /// An attempt to call add/update_monitor returned an Err (ie you did this!), causing the + /// An attempt to call watch/update_channel returned an Err (ie you did this!), causing the /// attempted action to fail. MonitorUpdateFailed, + /// [`KeysInterface::get_shutdown_scriptpubkey`] returned a shutdown scriptpubkey incompatible + /// with the channel counterparty as negotiated in [`InitFeatures`]. + /// + /// 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). + /// + /// [`KeysInterface::get_shutdown_scriptpubkey`]: crate::chain::keysinterface::KeysInterface::get_shutdown_scriptpubkey + /// [`InitFeatures`]: crate::ln::features::InitFeatures + IncompatibleShutdownScript { + /// The incompatible shutdown script. + script: ShutdownScript, + }, } impl fmt::Debug for APIError { @@ -46,6 +71,9 @@ impl fmt::Debug for APIError { APIError::RouteError {ref err} => f.write_str(err), APIError::ChannelUnavailable {ref err} => f.write_str(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) + }, } } }