X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Flightning%2Futil%2Ferrors.rs;h=8f0432685ee9f4cc9dd80ac8e490dcc884f0e1d3;hp=27d79c2bf72c32f456a00b97e99b626d24bc21a6;hb=68c220f7ee4fa0b6b4a300f56cd30b9b02ebfbdf;hpb=e2145963159417800486d4a12d3e193415a14792 diff --git a/lightning-c-bindings/src/lightning/util/errors.rs b/lightning-c-bindings/src/lightning/util/errors.rs index 27d79c2..8f04326 100644 --- a/lightning-c-bindings/src/lightning/util/errors.rs +++ b/lightning-c-bindings/src/lightning/util/errors.rs @@ -50,6 +50,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: crate::lightning::ln::script::ShutdownScript, + }, } use lightning::util::errors::APIError as nativeAPIError; impl APIError { @@ -83,6 +95,12 @@ impl APIError { } }, APIError::MonitorUpdateFailed => nativeAPIError::MonitorUpdateFailed, + APIError::IncompatibleShutdownScript {ref script, } => { + let mut script_nonref = (*script).clone(); + nativeAPIError::IncompatibleShutdownScript { + script: *unsafe { Box::from_raw(script_nonref.take_inner()) }, + } + }, } } #[allow(unused)] @@ -110,6 +128,11 @@ impl APIError { } }, APIError::MonitorUpdateFailed => nativeAPIError::MonitorUpdateFailed, + APIError::IncompatibleShutdownScript {mut script, } => { + nativeAPIError::IncompatibleShutdownScript { + script: *unsafe { Box::from_raw(script.take_inner()) }, + } + }, } } #[allow(unused)] @@ -142,6 +165,12 @@ impl APIError { } }, nativeAPIError::MonitorUpdateFailed => APIError::MonitorUpdateFailed, + nativeAPIError::IncompatibleShutdownScript {ref script, } => { + let mut script_nonref = (*script).clone(); + APIError::IncompatibleShutdownScript { + script: crate::lightning::ln::script::ShutdownScript { inner: Box::into_raw(Box::new(script_nonref)), is_owned: true }, + } + }, } } #[allow(unused)] @@ -169,6 +198,11 @@ impl APIError { } }, nativeAPIError::MonitorUpdateFailed => APIError::MonitorUpdateFailed, + nativeAPIError::IncompatibleShutdownScript {mut script, } => { + APIError::IncompatibleShutdownScript { + script: crate::lightning::ln::script::ShutdownScript { inner: Box::into_raw(Box::new(script)), is_owned: true }, + } + }, } } } @@ -213,3 +247,10 @@ pub extern "C" fn APIError_channel_unavailable(err: crate::c_types::Str) -> APIE /// Utility method to constructs a new MonitorUpdateFailed-variant APIError pub extern "C" fn APIError_monitor_update_failed() -> APIError { APIError::MonitorUpdateFailed} +#[no_mangle] +/// Utility method to constructs a new IncompatibleShutdownScript-variant APIError +pub extern "C" fn APIError_incompatible_shutdown_script(script: crate::lightning::ln::script::ShutdownScript) -> APIError { + APIError::IncompatibleShutdownScript { + script, + } +}