X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-c-bindings;a=blobdiff_plain;f=lightning-c-bindings%2Fsrc%2Fc_types%2Fmod.rs;h=471b067ac94fab9d19e1e6f034fdf49d1eea8cc2;hp=71aa6793cc25c9c3f2de853dedb9de0ff90e5f2b;hb=c9012b42c733d6acb43fae6be4c3c212f26d0c69;hpb=321d9d5103debfe4d5b92d8717fa4339e1d57969 diff --git a/lightning-c-bindings/src/c_types/mod.rs b/lightning-c-bindings/src/c_types/mod.rs index 71aa679..471b067 100644 --- a/lightning-c-bindings/src/c_types/mod.rs +++ b/lightning-c-bindings/src/c_types/mod.rs @@ -12,6 +12,7 @@ use bitcoin::secp256k1::Error as SecpError; use bitcoin::secp256k1::ecdsa::RecoveryId; use bitcoin::secp256k1::ecdsa::RecoverableSignature as SecpRecoverableSignature; use bitcoin::bech32; +use bitcoin::util::address; use core::convert::TryInto; // Bindings need at least rustc 1.34 use core::ffi::c_void; @@ -46,6 +47,18 @@ impl Into for u5 { fn into(self) -> bech32::u5 { bech32::u5::try_from_u8(self.0).expect("u5 objects must be in the range 0..32") } } +/// Integer in the range `0..=16` +#[derive(PartialEq, Eq, Copy, Clone)] +#[repr(C)] +pub struct WitnessVersion(u8); + +impl From for WitnessVersion { + fn from(o: address::WitnessVersion) -> Self { Self(o.into_num()) } +} +impl Into for WitnessVersion { + fn into(self) -> address::WitnessVersion { address::WitnessVersion::from_num(self.0).expect("WitnessVersion objects must be in the range 0..=16") } +} + #[derive(Clone)] #[repr(C)] /// Represents a valid secp256k1 public key serialized in "compressed form" as a 33 byte array.