X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Futil%2Ferrors.rs;h=6495d9de4ed5363fb4a2b70c958366653797121c;hb=c453d04137997f8ca2f79ae123b4915062e2f369;hp=f67621c828ca521f4739d99ec5a54760310cb1a8;hpb=879e309c128e2e2980846bfbb9a80a4c2bf8cbb4;p=rust-lightning diff --git a/lightning/src/util/errors.rs b/lightning/src/util/errors.rs index f67621c82..6495d9de4 100644 --- a/lightning/src/util/errors.rs +++ b/lightning/src/util/errors.rs @@ -9,11 +9,14 @@ //! 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)] +#[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. @@ -46,6 +49,18 @@ pub enum APIError { /// 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 { @@ -56,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) + }, } } }