X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=inline;f=lightning-c-bindings%2Fsrc%2Flightning%2Foffers%2Fparse.rs;h=34920bc2a4d66e5725b60d3a34c7ab33b7198ff8;hb=4870c930fc07067830277754bb6e42d7abd6e77f;hp=fc84acd63f9f99c3a1edea5b5f817a3d5ff09a92;hpb=5502fccd64611f16f5ebba3759c68b1a4d69b537;p=ldk-c-bindings diff --git a/lightning-c-bindings/src/lightning/offers/parse.rs b/lightning-c-bindings/src/lightning/offers/parse.rs index fc84acd..34920bc 100644 --- a/lightning-c-bindings/src/lightning/offers/parse.rs +++ b/lightning-c-bindings/src/lightning/offers/parse.rs @@ -99,6 +99,9 @@ pub(crate) extern "C" fn Bolt12ParseError_clone_void(this_ptr: *const c_void) -> pub extern "C" fn Bolt12ParseError_clone(orig: &Bolt12ParseError) -> Bolt12ParseError { orig.clone() } +/// Get a string which allows debug introspection of a Bolt12ParseError object +pub extern "C" fn Bolt12ParseError_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::parse::Bolt12ParseError }).into()} /// Error when interpreting a TLV stream as a specific type. #[derive(Clone)] #[must_use] @@ -150,6 +153,8 @@ pub enum Bolt12SemanticError { DuplicatePaymentId, /// Blinded paths were expected but were missing. MissingPaths, + /// Blinded paths were provided but were not expected. + UnexpectedPaths, /// The blinded payinfo given does not match the number of blinded path hops. InvalidPayInfo, /// An invoice creation time was expected but was missing. @@ -189,6 +194,7 @@ impl Bolt12SemanticError { Bolt12SemanticError::MissingPayerId => nativeBolt12SemanticError::MissingPayerId, Bolt12SemanticError::DuplicatePaymentId => nativeBolt12SemanticError::DuplicatePaymentId, Bolt12SemanticError::MissingPaths => nativeBolt12SemanticError::MissingPaths, + Bolt12SemanticError::UnexpectedPaths => nativeBolt12SemanticError::UnexpectedPaths, Bolt12SemanticError::InvalidPayInfo => nativeBolt12SemanticError::InvalidPayInfo, Bolt12SemanticError::MissingCreationTime => nativeBolt12SemanticError::MissingCreationTime, Bolt12SemanticError::MissingPaymentHash => nativeBolt12SemanticError::MissingPaymentHash, @@ -221,6 +227,7 @@ impl Bolt12SemanticError { Bolt12SemanticError::MissingPayerId => nativeBolt12SemanticError::MissingPayerId, Bolt12SemanticError::DuplicatePaymentId => nativeBolt12SemanticError::DuplicatePaymentId, Bolt12SemanticError::MissingPaths => nativeBolt12SemanticError::MissingPaths, + Bolt12SemanticError::UnexpectedPaths => nativeBolt12SemanticError::UnexpectedPaths, Bolt12SemanticError::InvalidPayInfo => nativeBolt12SemanticError::InvalidPayInfo, Bolt12SemanticError::MissingCreationTime => nativeBolt12SemanticError::MissingCreationTime, Bolt12SemanticError::MissingPaymentHash => nativeBolt12SemanticError::MissingPaymentHash, @@ -228,7 +235,8 @@ impl Bolt12SemanticError { } } #[allow(unused)] - pub(crate) fn from_native(native: &nativeBolt12SemanticError) -> Self { + pub(crate) fn from_native(native: &Bolt12SemanticErrorImport) -> Self { + let native = unsafe { &*(native as *const _ as *const c_void as *const nativeBolt12SemanticError) }; match native { nativeBolt12SemanticError::AlreadyExpired => Bolt12SemanticError::AlreadyExpired, nativeBolt12SemanticError::UnsupportedChain => Bolt12SemanticError::UnsupportedChain, @@ -253,6 +261,7 @@ impl Bolt12SemanticError { nativeBolt12SemanticError::MissingPayerId => Bolt12SemanticError::MissingPayerId, nativeBolt12SemanticError::DuplicatePaymentId => Bolt12SemanticError::DuplicatePaymentId, nativeBolt12SemanticError::MissingPaths => Bolt12SemanticError::MissingPaths, + nativeBolt12SemanticError::UnexpectedPaths => Bolt12SemanticError::UnexpectedPaths, nativeBolt12SemanticError::InvalidPayInfo => Bolt12SemanticError::InvalidPayInfo, nativeBolt12SemanticError::MissingCreationTime => Bolt12SemanticError::MissingCreationTime, nativeBolt12SemanticError::MissingPaymentHash => Bolt12SemanticError::MissingPaymentHash, @@ -285,6 +294,7 @@ impl Bolt12SemanticError { nativeBolt12SemanticError::MissingPayerId => Bolt12SemanticError::MissingPayerId, nativeBolt12SemanticError::DuplicatePaymentId => Bolt12SemanticError::DuplicatePaymentId, nativeBolt12SemanticError::MissingPaths => Bolt12SemanticError::MissingPaths, + nativeBolt12SemanticError::UnexpectedPaths => Bolt12SemanticError::UnexpectedPaths, nativeBolt12SemanticError::InvalidPayInfo => Bolt12SemanticError::InvalidPayInfo, nativeBolt12SemanticError::MissingCreationTime => Bolt12SemanticError::MissingCreationTime, nativeBolt12SemanticError::MissingPaymentHash => Bolt12SemanticError::MissingPaymentHash, @@ -400,6 +410,10 @@ pub extern "C" fn Bolt12SemanticError_duplicate_payment_id() -> Bolt12SemanticEr pub extern "C" fn Bolt12SemanticError_missing_paths() -> Bolt12SemanticError { Bolt12SemanticError::MissingPaths} #[no_mangle] +/// Utility method to constructs a new UnexpectedPaths-variant Bolt12SemanticError +pub extern "C" fn Bolt12SemanticError_unexpected_paths() -> Bolt12SemanticError { + Bolt12SemanticError::UnexpectedPaths} +#[no_mangle] /// Utility method to constructs a new InvalidPayInfo-variant Bolt12SemanticError pub extern "C" fn Bolt12SemanticError_invalid_pay_info() -> Bolt12SemanticError { Bolt12SemanticError::InvalidPayInfo} @@ -415,3 +429,6 @@ pub extern "C" fn Bolt12SemanticError_missing_payment_hash() -> Bolt12SemanticEr /// Utility method to constructs a new MissingSignature-variant Bolt12SemanticError pub extern "C" fn Bolt12SemanticError_missing_signature() -> Bolt12SemanticError { Bolt12SemanticError::MissingSignature} +/// Get a string which allows debug introspection of a Bolt12SemanticError object +pub extern "C" fn Bolt12SemanticError_debug_str_void(o: *const c_void) -> Str { + alloc::format!("{:?}", unsafe { o as *const crate::lightning::offers::parse::Bolt12SemanticError }).into()}