"core::convert::Infallible" => Some("crate::c_types::NotConstructable"),
+ "bitcoin::bech32::Error"|"bech32::Error"
+ if !is_ref => Some("crate::c_types::Bech32Error"),
+ "bitcoin::secp256k1::Error"|"secp256k1::Error"
+ if !is_ref => Some("crate::c_types::Secp256k1Error"),
+
+ "core::num::ParseIntError" => Some("crate::c_types::Error"),
+ "core::str::Utf8Error" => Some("crate::c_types::Error"),
+
"bitcoin::bech32::u5"|"bech32::u5" => Some("crate::c_types::u5"),
"core::num::NonZeroU8" => Some("u8"),
if is_ref => Some("*const [u8; 32]"),
"bitcoin::secp256k1::key::SecretKey"|"bitcoin::secp256k1::SecretKey"
if !is_ref => Some("crate::c_types::SecretKey"),
- "bitcoin::secp256k1::Error"|"secp256k1::Error"
- if !is_ref => Some("crate::c_types::Secp256k1Error"),
"bitcoin::blockdata::script::Script" if is_ref => Some("crate::c_types::u8slice"),
"bitcoin::blockdata::script::Script" if !is_ref => Some("crate::c_types::derived::CVec_u8Z"),
"bitcoin::blockdata::transaction::OutPoint" => Some("crate::lightning::chain::transaction::OutPoint"),
"core::convert::Infallible" => Some("panic!(\"You must never construct a NotConstructable! : "),
+ "bitcoin::bech32::Error"|"bech32::Error" if !is_ref => Some(""),
+ "bitcoin::secp256k1::Error"|"secp256k1::Error" if !is_ref => Some(""),
+
+ "core::num::ParseIntError" => Some("u8::from_str_radix(\" a\", 10).unwrap_err() /*"),
+ "core::str::Utf8Error" => Some("core::str::from_utf8(&[0xff]).unwrap_err() /*"),
+
"std::time::Duration"|"core::time::Duration" => Some("core::time::Duration::from_secs("),
"std::time::SystemTime" => Some("(::std::time::SystemTime::UNIX_EPOCH + std::time::Duration::from_secs("),
"core::convert::Infallible" => Some("\")"),
+ "bitcoin::bech32::Error"|"bech32::Error" if !is_ref => Some(".into_rust()"),
+ "bitcoin::secp256k1::Error"|"secp256k1::Error" if !is_ref => Some(".into_rust()"),
+
+ "core::num::ParseIntError" => Some("*/"),
+ "core::str::Utf8Error" => Some("*/"),
+
"std::time::Duration"|"core::time::Duration" => Some(")"),
"std::time::SystemTime" => Some("))"),
"core::convert::Infallible" => Some("panic!(\"Cannot construct an Infallible: "),
+ "bitcoin::bech32::Error"|"bech32::Error"
+ if !is_ref => Some("crate::c_types::Bech32Error::from_rust("),
+ "bitcoin::secp256k1::Error"|"secp256k1::Error"
+ if !is_ref => Some("crate::c_types::Secp256k1Error::from_rust("),
+
+ "core::num::ParseIntError" => Some("crate::c_types::Error { _dummy: 0 } /*"),
+ "core::str::Utf8Error" => Some("crate::c_types::Error { _dummy: 0 } /*"),
+
"bitcoin::bech32::u5"|"bech32::u5" => Some(""),
"bitcoin::secp256k1::key::PublicKey"|"bitcoin::secp256k1::PublicKey"|"secp256k1::key::PublicKey"
if is_ref => Some(""),
"bitcoin::secp256k1::key::SecretKey"|"bitcoin::secp256k1::SecretKey"
if !is_ref => Some("crate::c_types::SecretKey::from_rust("),
- "bitcoin::secp256k1::Error"|"secp256k1::Error"
- if !is_ref => Some("crate::c_types::Secp256k1Error::from_rust("),
"bitcoin::blockdata::script::Script" if is_ref => Some("crate::c_types::u8slice::from_slice(&"),
"bitcoin::blockdata::script::Script" if !is_ref => Some(""),
"bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" if is_ref => Some("crate::c_types::Transaction::from_bitcoin("),
"core::convert::Infallible" => Some("\")"),
+ "bitcoin::secp256k1::Error"|"bech32::Error"
+ if !is_ref => Some(")"),
+ "bitcoin::secp256k1::Error"|"secp256k1::Error"
+ if !is_ref => Some(")"),
+
+ "core::num::ParseIntError" => Some("*/"),
+ "core::str::Utf8Error" => Some("*/"),
+
"bitcoin::bech32::u5"|"bech32::u5" => Some(".into()"),
"bitcoin::secp256k1::key::PublicKey"|"bitcoin::secp256k1::PublicKey"|"secp256k1::key::PublicKey"
if !is_ref => Some(")"),
"bitcoin::secp256k1::key::SecretKey"|"bitcoin::secp256k1::SecretKey"
if is_ref => Some(".as_ref()"),
- "bitcoin::secp256k1::Error"|"secp256k1::Error"
- if !is_ref => Some(")"),
"bitcoin::blockdata::script::Script" if is_ref => Some("[..])"),
"bitcoin::blockdata::script::Script" if !is_ref => Some(".into_bytes().into()"),
"bitcoin::blockdata::transaction::Transaction"|"bitcoin::Transaction" => Some(")"),
SecpError::NotEnoughMemory => Secp256k1Error::NotEnoughMemory,
}
}
+ pub(crate) fn into_rust(self) -> SecpError {
+ match self {
+ Secp256k1Error::IncorrectSignature => SecpError::IncorrectSignature,
+ Secp256k1Error::InvalidMessage => SecpError::InvalidMessage,
+ Secp256k1Error::InvalidPublicKey => SecpError::InvalidPublicKey,
+ Secp256k1Error::InvalidSignature => SecpError::InvalidSignature,
+ Secp256k1Error::InvalidSecretKey => SecpError::InvalidSecretKey,
+ Secp256k1Error::InvalidRecoveryId => SecpError::InvalidRecoveryId,
+ Secp256k1Error::InvalidTweak => SecpError::InvalidTweak,
+ Secp256k1Error::TweakCheckFailed => SecpError::TweakCheckFailed,
+ Secp256k1Error::NotEnoughMemory => SecpError::NotEnoughMemory,
+ }
+ }
+}
+
+#[repr(C)]
+#[derive(Copy, Clone)]
+/// Represents an error returned from the bech32 library during validation of some bech32 data
+pub enum Bech32Error {
+ /// String does not contain the separator character
+ MissingSeparator,
+ /// The checksum does not match the rest of the data
+ InvalidChecksum,
+ /// The data or human-readable part is too long or too short
+ InvalidLength,
+ /// Some part of the string contains an invalid character
+ InvalidChar(u32),
+ /// Some part of the data has an invalid value
+ InvalidData(u8),
+ /// The bit conversion failed due to a padding issue
+ InvalidPadding,
+ /// The whole string must be of one case
+ MixedCase,
+}
+impl Bech32Error {
+ pub(crate) fn from_rust(err: bech32::Error) -> Self {
+ match err {
+ bech32::Error::MissingSeparator => Self::MissingSeparator,
+ bech32::Error::InvalidChecksum => Self::InvalidChecksum,
+ bech32::Error::InvalidLength => Self::InvalidLength,
+ bech32::Error::InvalidChar(c) => Self::InvalidChar(c as u32),
+ bech32::Error::InvalidData(d) => Self::InvalidData(d),
+ bech32::Error::InvalidPadding => Self::InvalidPadding,
+ bech32::Error::MixedCase => Self::MixedCase,
+ }
+ }
+ pub(crate) fn into_rust(self) -> bech32::Error {
+ match self {
+ Self::MissingSeparator => bech32::Error::MissingSeparator,
+ Self::InvalidChecksum => bech32::Error::InvalidChecksum,
+ Self::InvalidLength => bech32::Error::InvalidLength,
+ Self::InvalidChar(c) => bech32::Error::InvalidChar(core::char::from_u32(c).expect("Invalid UTF-8 character in Bech32Error::InvalidChar")),
+ Self::InvalidData(d) => bech32::Error::InvalidData(d),
+ Self::InvalidPadding => bech32::Error::InvalidPadding,
+ Self::MixedCase => bech32::Error::MixedCase,
+ }
+ }
+}
+
+#[repr(C)]
+#[derive(Clone, Copy, PartialEq)]
+/// Sub-errors which don't have specific information in them use this type.
+pub struct Error {
+ /// Zero-Sized_types aren't consistent across Rust/C/C++, so we add some size here
+ pub _dummy: u8,
}
#[repr(C)]